[CMake] granular preprocessor defiitions

Brad King brad.king at kitware.com
Wed Apr 4 08:23:29 EDT 2012


On 4/3/2012 9:33 PM, Christoph Anton Mitterer wrote:
> Actually what I'd prefer most if add_definitions (and perhaps even
> include_directories) could be set in a per file context[0].

add_definitions is the original interface and uses -D in its syntax for
historical reasons.  The earliest quick-and-dirty implementation allowed
arbitrary flags so people started abusing it.  Then we had to support
such projects for compatibility.

These days you can set the COMPILE_DEFINITIONS property on a per-directory,
per-target, and per-source basis (and even per-configuration):

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_dir:COMPILE_DEFINITIONS
  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:COMPILE_DEFINITIONS
  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_sf:COMPILE_DEFINITIONS

CMake 2.8.8 adds support for per-target INCLUDE_DIRECTORIES.

-Brad


More information about the CMake mailing list