libtorrent version (or branch): new-disk-io
platform/architecture: linux
the cmake build is failing. I suspect the relevant difference from master is that this branch builds against boost from source. i.e. it pulls in boost from a user-downloaded location, rather than the system include directory.
Here's the error message: https://travis-ci.org/arvidn/libtorrent/jobs/390536230#L9543
CMake Error in CMakeLists.txt:
Target "torrent-rasterbar" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
"/home/travis/build/arvidn/libtorrent/boost_1_64_0"
which is prefixed in the source directory.
@zeule do you have any hints of how to solve this?
The problem arises because we export target properties when installing *Targets.cmake file. With this configuration CMake would need to export a path to the source tree, it assumes that to be an error and signals early, even before we try to make the install target. Three obvious solutions (on CMakeListst.txt level) would be a) move boost sources out of the libtorrent source tree or b) supply the boost include paths as $<BUILD_INTERFACE:. I assume that you need the boost to be inside of the source tree for b2 to work. Am I right? If so, the only solution I see is adding an option to the CMake build in order to optionally replace
target_include_directories(torrent-rasterbar PUBLIC ${Boost_INCLUDE_DIRS})
with
target_include_directories(torrent-rasterbar PUBLIC $<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>)
That would make exported targets invalid due to empty INTERFACE_INCLUDE_DIRECTORIES.
The third solution c) is to also add an option, that would make conditional all the install() commands, which would make CMake happy, as far as I understood.
I would prefer (a), or (c) if (a) is impossible, while (b) seem to be the simplest one.
Update: for the third solutions not all install() commands need to be removed, but seems like removing only install(EXPORT) one will do the trick. In that case, the option gets meaning "install-cmake-package` or something like that.
oh, the only reason the boost directory is inside the libtorrent directory was to save a few lines in the .travis script when downloading and unzipping the boost package. You're saying if I just cd .. before doing that, it might just work?
I don't expect any normal build to actually have the boost directory there, so I think it's fine to require it be outside
OK, but if moving the boost source directory does not help (unlikely, but jut in case), I can submit a PR with changes according to (c).
fixed. thanks!
My pleasure.
Most helpful comment
The problem arises because we export target properties when installing *Targets.cmake file. With this configuration CMake would need to export a path to the source tree, it assumes that to be an error and signals early, even before we try to make the install target. Three obvious solutions (on CMakeListst.txt level) would be a) move boost sources out of the libtorrent source tree or b) supply the boost include paths as
$<BUILD_INTERFACE:. I assume that you need the boost to be inside of the source tree for b2 to work. Am I right? If so, the only solution I see is adding an option to the CMake build in order to optionally replacewith
That would make exported targets invalid due to empty INTERFACE_INCLUDE_DIRECTORIES.
The third solution c) is to also add an option, that would make conditional all the
install()commands, which would make CMake happy, as far as I understood.I would prefer (a), or (c) if (a) is impossible, while (b) seem to be the simplest one.