[Insight-developers] CMake variables and preprocessor directives

Brad King brad.king at kitware.com
Thu Feb 20 10:15:41 EST 2014


On 02/20/2014 10:04 AM, Bradley Lowekamp wrote:
> add them as command line defines with some add_definition commands?

If the application specifies its own list of components when calling
find_package(ITK) then it already knows what modules it is using.
It is only when using "all" modules that happen to have been built
with ITK that the application may need to get information like this.
The ITKConfig.cmake file already provides it as:

- ITK_MODULES_ENABLED = modules enabled when ITK was built
- ITK_MODULES_REQUESTED = modules requested by app, or all enabled

If an application needs this information at the preprocessor level
it should do its own thing based on its own needs.  It could be
as simple as

 set_property(DIRECTORY APPEND PROPERTY
   COMPILE_DEFINITIONS ${ITK_MODULES_REQUESTED})

but that could make command lines somewhat long.  IMO the approach
of using configure_file for specific modules is best.

-Brad K



More information about the Insight-developers mailing list