Vcpkg: Using vcpkg repo with cmake not adding include paths

Created on 14 Mar 2017  路  5Comments  路  Source: microsoft/vcpkg

According to docs, it should be enough to specify the toolchain file (vcpkg.cmake) on config command for cmake. However, that does not add the vcpkg/installed//include to the generated compile instructions.

If I explicitely add the vcpkg/installed//include to the CMakeLists.txts file, then it works
(Or just add Boost_INCLUDE_DIR, since points to all the includes...)

I don't know if that is a bug of cmake 3.8.rc2 or, vcpkg.cmake, or if i'm doing something wrong.
I'm using the cmake-usage sample from the (old) wiki, except instead of sqlite, I'm including boost/asio.hpp. Everything else is the same (hello worlr type main.cpp, cmakelists finding boost system, instead of sqlite).

Coinfiguring works, but build doesn't, complaining can't find boost/asio.hpp....
same with others. e.g. rapidxml

IIRC it used to work earlier, but not sure. Using version
0.0.76-d46563d862228241124bfa345c6b0d80b0efac7b

documentation

Most helpful comment

I highly recommend we add this to the documentation about CMake immediately. I just ran into the exact same issue and was awfully confused until I found this issue.

All 5 comments

We don't add the include path by default anymore because we have no way to ensure we add the path to the _end_ of your compiler line. If your sources happen to share a header with one that is installed inside Vcpkg, we don't want to override your header.

The fix, fortunately, is quite easy: just pick any header that you're expecting to get out of Vcpkg, then do

find_path(SYSTEM_INCLUDE_DIR zlib.h)
include_directories(${SYSTEM_INCLUDE_DIR})

This lets you control exactly where in your compiler line it gets added. You will usually want it added at the end.

Ok, so the workaround I'm using (as described in the OP) is also what you would suggest.
It might be better to just define a generic 'vcpkg_Include_dir' to use, otherwise one would have to add documentation to the Cmakelists fiel why only one of the include dirs are being used

Thx.

I highly recommend we add this to the documentation about CMake immediately. I just ran into the exact same issue and was awfully confused until I found this issue.

Thanks for showing how important this is! I've extended the documentation with
a6957eb, please take a look and make sure it would have helped you :)

It's awesome! Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

invy picture invy  路  3Comments

cskrisz picture cskrisz  路  3Comments

PhilLab picture PhilLab  路  3Comments

jack17529 picture jack17529  路  3Comments

madkoala picture madkoala  路  3Comments