How can I get all include directories of my executable? I want to introduce cppcheck and I need to forward all include directories to cppcheck (also the include directories of the interface imported libraries).
So for example I have
add_executable(my_exe main.cpp)
target_link_libraries(my_exe PRIVATE RapidJSON::RapidJSON)
How can I get all corresponding include directories of my_exe, including the RapidJSON ones (e.g. ~/.conan/data/RapidJSON/1.1.0/a/b/package/x/include)?
I tried following without success :-(
get_target_property(ALL_INCLUDES my_exe INTERFACE_INCLUDE_DIRECTORIES) # NOTFOUND
get_target_property(ALL_INCLUDES my_exe INCLUDE_DIRECTORIES) # empty
add_executable(my_exe main.cpp)
target_link_libraries(my_exe PRIVATE RapidJSON::RapidJSON)
# the following line should be adapted so that the variable cppcheck_includes also contains the RapidJSON include directories
set(cppcheck_includes ${CMAKE_SOURCE_DIR}/includes)
add_custom_target(cppcheck
COMMAND cppcheck
--enable=all
--std=c++11
--library=/usr/share/cppcheck/cfg/std.cfg
--check-config
${cppcheck_includes}
main.cpp
)
I expect that there is no warning, but there is a warning:
Include file: <rapidjson/document.h> not found.