mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.89k stars 374 forks source link

Add include directory to tins target #465

Open delins opened 2 years ago

delins commented 2 years ago

If you make install libtins to the system's default location, a user only needs to do:

find_package(libtins CONFIG REQUIRED)
target_link_libraries(mytarget PUBLIC tins)

and #include <tins/tins.h> works because the headers can be found in the default location.

However, if you installed libtins to a different path using -DCMAKE_INSTALL_PREFIX=mypath and help cmake find libtins using -DCMAKE_PREFIX_PATH=mypath, cmake can't find the header files.

To my understanding, this happens because libtins' CmakeLists.txt doesn't call target_include_directories on the tins target. If it did and the export code does its work, the call to target_link_libraries shown above would automatically pull in the include directory in mypath/include and add them to the mytarget target.

libtins does provide the LIBTINS_INCLUDE_DIRS variable, but for me at least that points to the include directory in the cloned git repo, which isn't ideal (may be similar to #340).

I'd love to create a pull request but I don't know enough about CMake to know how to do this properly, let alone to integrate this into the current CMakeLists.txt