Answer the question
In order to leave comments, you need to log in
How to write CMakeLists.txt correctly?
Good afternoon, there was a problem in writing a file for cmake. I tried to solve it myself, but in the lessons, as a rule, most of the examples use standard situations.
In particular, I have this problem.
Here is the project structure:
src/
main.cpp
class1.cpp
class2.cpp
class3.cpp
include/
class1.h
class2.h
class3.h
Plus there are three more header files that are used by other libraries. All of them are in the system folder in /usr/include in ubuntu. They also use two keys. Actually, the difficulty lies in the fact that, as a rule, these are not some kind of modular libraries that are in folders, but simply header files. Moreover, I would like to make it so that I do not explicitly specify the path, but cmake itself looked for them.
I would like to see an example of how it should look or at least point in the right direction.
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
First you look for the CMake library (find_package/pkg_check_modules/find_path), they set the CACHE defined variables that you use in your target properties (target_link_libaries). If the external library does not support searching through CMake, then they usually write and include the FindSomeLib.cmake file, where they call the basic search utilities (like find_path) and create an IMPORTED target containing all the necessary flags for compilation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question