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

Angeliki Chrysochou angeliki.chrysochou at gmail.com
Tue Dec 2 13:33:26 EST 2014


Hi Chris,

Given your file structure

The file structure:
.
|-- bin/
|-- include/
|   `-- mylib/
|-- lib/
`-- src/
    |-- CMakeLists.txt
    |-- mylib/
    |   |-- CMakeLists.txt
    |   |-- myfunc.cpp
    |   `-- myfunc.h
    `-- prog/
        |-- CMakeLists.txt
        `-- prog.cpp

you should add in ./src/prog/CMakeLists.txt in include_directories the
correct path to myfunc.h. Assuming CMAKE_SOURCE_DIR is "." (this is where
your top level CMakeLists.txt is located):

include_directories(${CMAKE_SOURCE_DIR}/src/mylib)

Cheers!
Angeliki


On Tue, Dec 2, 2014 at 7: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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141202/892d77f8/attachment.html>


More information about the CMake mailing list