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
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to