[CMake] How to query compiler definitions?
Michael Wild
themiwi at gmail.com
Thu Jan 20 07:56:46 EST 2011
On 01/20/2011 01:30 PM, SF Markus Elfring wrote:
>> get_directory_property(info COMPILE_DEFINITIONS)
>
> How do you think about an extension for this programming interface?
>
> Would you like to support that target parameters like preprocessor
> symbols are queried from the build environment even if they were not set
> by the CMake command "add_definitions" explicitly?
>
> Regards,
> Markus
Probably that would be pretty difficult to achieve and definitely would
break backwards-compatibility beyond resurrection.
OTOH, I really think that you're on the wrong track here. You shouldn't
check for a preprocessor symbol in CMake. Instead, probably do a
find_package(TinyXML) and then depending on the result offer the user an
option variable (e.g. ENABLE_DEBUGGING_FUNCTIONS), define a preprocessor
symbol HAVE_TINYXML which you then use in your code together with NDEBUG
to determine whether to
- don't call the debugging functions at all (NDEBUG defined)
- either provide dummy/stub debugging functions or #error out (NDEBUG
and HAVE_TINYXML not defined)
- call the debugging functions (NDEBUG not defined, HAVE_TINYXML defined)
This would put the load on the users shoulders, but it should be pretty
clear for him what is expected and how to handle things. The INSTALL
document can also help there.
Michael
More information about the CMake
mailing list