[ACCEPTED]-cmake add_definitions and COMPILE_DEFINITIONS, how to see them-cmake

Accepted answer
Score: 27

You want to extract the COMPILE_DEFINITIONS 7 property from the directory. E.g. use the following:

add_definitions( -DDebug )
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )

Then 6 you can simply iterate over them, e.g.:

foreach( d ${DirDefs} )
    message( STATUS "Found Define: " ${d} )
endforeach()
message( STATUS "DirDefs: " ${DirDefs} )

Note 5 that definitions may also be associated 4 with targets or source-files instead of directories. And note 3 that they can differ between configurations. Depending 2 on your requirements, you may need to check 1 a large set of different properties.

More Related questions