B
B
BelBES2015-02-03 23:06:03
linux
BelBES, 2015-02-03 23:06:03

How to get include paths from cmake file?

Hello!
I had such a problem: there is an abstract project in C ++, it uses the CMake automatic build system. At the same time, it can consist of several cmake files, inside each CMakeFiles.txt there can be several calls to find_package and several variables that store the paths to the includes. The task is to get the paths to all the includes and libraries that are used inside the project for such an arbitrary project. Crawling through the folder that cmake generates did not give any results, studying the codes of the cmake'plugin for QTCreator'a too. Does anyone know how to get such a thing? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AxisPod, 2015-02-04
@AxisPod

The scope of CMake is quite interesting and the scopes are created by folders / functions, macros are substituted into the code and the scope will be taken at the place of substitution. All variables created in a higher folder will be visible in subfolders. You can create your own variable where to put all the includes and then use them. If you need to change in the child, you can use the list operation, although I'm not sure what will be reflected correctly, as well as the PARENT_SCOPE modifier. Of course, you can still use the CACHE modifier, but then it can be changed from the command line.
www.cmake.org/cmake/help/v3.0/command/set.html

D
Dmitry Vyalkov, 2015-09-05
@DmitryVyalkov

As an option, in the library search block, insert the output of the path to the console with the label by which you will search,
message(STATUS "LibPath: " ${LIBXML2_INCLUDE_DIRS})
Well, then we parse the output of cmake to search for these lines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question