D
D
dearname2016-01-30 07:39:55
C++ / C#
dearname, 2016-01-30 07:39:55

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

2 answer(s)
S
Sergey Nizovtsev, 2016-05-12
@snizovtsev

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.

K
KorsaR-ZN, 2014-09-08
@KorsaR-ZN

If this is the entire problem area, then most likely the last dot should be a comma ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question