strukturag / libde265

Open h.265 video codec implementation.
Other
1.7k stars 457 forks source link

CMake: include directories not propagated with target #404

Open KerstinKeller opened 1 year ago

KerstinKeller commented 1 year ago

When you build and install libde265 with CMake, you cannot properly use the library after using target_link_libraries, because the include directories are not propagated properly.

The reason is this line: https://github.com/strukturag/libde265/blob/0b1752abff97cb542941d317a0d18aa50cb199b1/libde265/CMakeLists.txt#L132

You also need to state where the header files can be found in the installed case, for an example like this: https://github.com/eclipse-ecal/tcp_pubsub/blob/4ceafb6b55ce41149ed9473dae7e8ea37235a3cc/tcp_pubsub/CMakeLists.txt#L96-L103

Sample CMakeLists.txt file to use libde265:

cmake_minimum_required(VERSION 3.15)
project(libde265PackageTest CXX)

find_package(libde265 REQUIRED)
add_executable(libde265_test libde265_test.cpp)
target_link_libraries(libde265_test PRIVATE  de265)

Building a sample then fails:

fatal error: de265-version.h: No such file or directory

Would you accept a PR to address this issue? At the same time I would recommend to export targets into a namespace so they can be linked with libde265::libde265, to make clear to CMake that this target is imported and then it gets better diagnostics if it cannot be found.

farindk commented 1 year ago

Thank you. Sure, if you have a PR ready, I would integrate this. I don't know all CMake details, so every input is welcome. Please note that we currently can only use CMake up to 3.10 (preferably a bit lower) because of the packaging for old distributions.