[CMake] INTERFACE library and path to source.
Eric Noulard
eric.noulard at gmail.com
Fri Dec 8 10:42:52 EST 2017
Hi there,
I encounter a weird issue with header-only library.
Somewhere in my source tree I have an header library which consist in a
bunch of headers:
The concerned CMakeLists.txt looks like this:
add_library(MyHeaderLIB INTERFACE)
target_include_directories(MyHeaderLIB INTERFACE
${CMAKE_CURRENT_SOURCE_DIR})
target_sources(MyHeaderLIB INTERFACE
whatever.h)
Somewhere else (in another directory) I have another CMakeLists.txt:
add_executable(myexe myexe.cpp)
target_link_libraries(myexe MyHeaderLIB)
and CMake complains when processing it that he cannot find "whatever.h"...
The problem disappear if I use full path in target_source, i.e.:
target_sources(MyHeaderLIB INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/whatever.h)
Why should I do that?
I this the expected behavior / way to create header only library?
--
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171208/c3ebe66b/attachment.html>
More information about the CMake
mailing list