[Insight-developers] CMake variables and preprocessor directives
Padfield, Dirk R (GE Global Research)
padfield at research.ge.com
Wed Feb 19 15:08:19 EST 2014
Hi All,
I have a question about CMake variables and preprocessor directives. I have a local project built using CMake that relies on ITK. Some of the filters in this project rely on ITK filters that are in ITKReview. I want to do the right thing in the CMake of my local project by checking for the ITKReview flag and then excluding all of my local filters that depend on ITKReview if the flag is not set.
This process worked fine when using "ITK_USE_REVIEW", but this flag has been deprecated now. Xiaoxiao told me that the right flag to use is "ITKReview_LOADED" instead of "Module_ITKReview", and the CMake of my local project can now read successfully the "ITKReview_LOADED" flag.
However, I am still having trouble with a closely related question: is there a preprocessor directive for that flag as well? For example, in my local project I have all of my tests in REGISTER_TEST commands in an AlgorithmsTests.cxx file (this is the same structure we used to have in ITK). Here is the code:
#if defined(ITK_USE_REVIEW) || defined(ITKReview_LOADED) || defined(Module_ITKReview)
REGISTER_TEST(MyTest);
#endif
However, this code is ignored even when I have the Module_ITKReview CMake variable set. But if I link against a previous version of ITK with ITK_USE_REVIEW, it works!
Xiaoxiao pointed me to the #cmakedefine commands, and I noticed that in the itkConfigure.h.in file of InsightToolkit-3.20.1, there is
#cmakedefine ITK_USE_REVIEW
I tried doing a similar thing by adding the following line in Modules/Core/Common/src/itkConfigure.h of the most recent ITK:
#cmakedefine ITKReview_LOADED
This did not work, so I tried putting the same line in the itkConfigure.h.in of my local project, but that didn't work either. I also tried the following lines to no avail:
#define ITKReview_LOADED @ITKReview_LOADED@
#define ITKReview_LOADED
So, my question is: in my local project, how do I access a preprocessor variable from ITK that tells whether ITKReview is on?
Many thanks,
Dirk
More information about the Insight-developers
mailing list