[CMake] Method to get effective include_directories and compile_definitions

Lars Christensen larsch at belunktum.dk
Mon Feb 10 03:55:10 EST 2014


Hello,

Is there a way to get the effective include directories and compile
definitions for a target, including those specified at the directory level
and any INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITION on
targets that are required via target_link_libraries?

Iterating recursively over LINK_LIBRARIES to find interface
include/definition is the alternative, but I guess I'd need to handle
non-target dependencies, as well as possible cyclic dependencies.

Ideas?

Example:

include_directories(/path/to/common)
add_definitions(-DCOMMON=1)

add_library(lib1 lib1.c)
target_include_directories(lib1 PUBLIC /path/to/lib1)
target_compile_definitions(lib1 PUBLIC -DLIB1=1)

add_library(lib2 lib2.c)
target_include_directories(lib2 PUBLIC /path/to/lib2)
target_compile_definitions(lib2 PUBLIC -DLIB2=1)

target_link_libraries(lib2 lib1)

How would I get all 3 include directories and definitions for lib2 into
variables? The INCLUDE_DIRECTORIES property on the lib2 target only
includes the common and lib2-specific include directory, while the
COMPILE_DEFINITIONS property only includes the specific definition, not
even the directory-level definition (COMMON).

I'm trying to generate PC-Lint configuration files and need the definitions
and include directories. The wiki solution no longer works with interface
include_directories and compile_definitions.

Lars
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140210/a6152ab1/attachment.html>


More information about the CMake mailing list