grantila / q

A platform-independent promise library for C++, implementing asynchronous continuations.
http://libq.io
Apache License 2.0
193 stars 24 forks source link

Export libq public headers #10

Closed jupp0r closed 7 years ago

jupp0r commented 7 years ago

In order to more easily consume libq from other CMake projects, this change exposes the public headers as part of the library target. This automatically sets target_include_directories for targets that link against libq. See https://rix0r.nl/blog/2015/08/13/cmake-guide/ for more details.

grantila commented 7 years ago

What are you doing in your cmake project to include q? I'm gonna spend some time making sure this works fine also for q-test as well as when packaging q. I haven't thought much about using q as a cmake-dependency as you've realized, but it's a good point to be able to.

jupp0r commented 7 years ago

I'm writing a library that returns promises on its public interface. The exported config for libq allow consumers of my library to automatically include libq headers, linker flags, etc. All I'd have to do is

add_subdirectory(external/q)
target_link_libraries(my_library q)

Then consumers of my library would have to

target_link_libraries(their_library my_library)

When you have a deep dependency tree, it's increasingly important to let CMake handle include_directories and linker flags for you.

Regarding q-test, would you be interested in a patch that applies the same technique there?

grantila commented 7 years ago

@jupp0r yes that would be needed (or at least very much preferred) to have both q and q-test exported. I've tried, without success, since the google test's gtest_main is not in the "export set". So I get this:

CMake Error: install(EXPORT "QTestConfig" ...) includes target "q-test" which requires target "gtest_main" that is not in the export set.

Your help is highly appreciated!

grantila commented 7 years ago

Note, this is in the cmake-targets branch