[CMake] How to set path to library header files?

David Cole DLRdave at aol.com
Tue Dec 2 13:42:48 EST 2014


This chunk:

target_include_directories(
    mylib PUBLIC
    # Headers used from source/build location:
    "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
    # Headers used from the installed location:
    "$<INSTALL_INTERFACE:include>"
)

uses CMAKE_CURRENT_SOURCE_DIR, which already ends with "/mylib".

Don't you need to use the parent directory in order to include "mylib/..." ?

Once you have that correct, the settings should propagate to the prog
executable as well via your target_link_libraries call.


D



On Tue, Dec 2, 2014 at 1:04 PM, Chris Johnson <cxjohnson at gmail.com> wrote:
> Adding this directive does not seem to change the results at all, actually.
> Am I missing something?
>
> Thanks,
> ..chris
>
> On Tue, Dec 2, 2014 at 11:33 AM, Bill Hoffman <bill.hoffman at kitware.com>
> wrote:
>>
>> This should work:
>>
>> include_directories(${CMAKE_SOURCE_DIR}/src)
>>
>
> --
>
> 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


More information about the CMake mailing list