xtensor: Unable use project as sub directory
In my project, I added xtl
, xsimd
and xtensor
as submodules and then in my CMakeLists.txt
set(BUILD_TESTS "" CACHE BOOL OFF)
set(BUILD_EXAMPLES "" CACHE BOOL OFF)
set(DOWNLOAD_GTEST "" CACHE BOOL OFF)
set(ENABLE_FALLBACK "" CACHE BOOL ON)
set(XTENSOR_USE_XSIMD "" CACHE BOOL ON)
add_subdirectory(xtl)
add_subdirectory(xsimd)
add_subdirectory(xtensor)
The cmake failed configure due to xtensor
try to find_package
.
I think in this case the CMakeLists.txt for xtensor
et. al. should identify itself is added as subproject and do not find_package
at all, just target_link_libraries
e.g., with the test of
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
BTW, is there better solution in this case?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (12 by maintainers)
The problem is not actually finding
xtensor
, but the very fact that the main officially supported way of using it is via installing it into the environment. Header-only libraries should never need to be installed. For me, change control is an integral part of dependency management. In our company, all build processes are required not to depend on the system environment except very basic libraries (i.e. what is available from a fresh system install). All other dependencies must be managed by each project itself. Within CI, there are plenty of tools managing the environment to deal with system-installing dependencies. But the developer experience suffers.Using
gitsub*
for that purpose is certainly not the best possible way, but it is convenient for small projects that are otherwise self-contained. Now, we can of course just do a separatein our projects, and then go on with possible compilation options
-DXTENSOR_USE_XSIMD
etc. Butadd_subproject(.../xtensor)
would be more convenient and help avoiding duplicate effort.I don’t want to convince anyone that he should be using
gitsub*
- that’s not the point. I’m just looking for an improved experience usingxtensor
via CMake without installing, directly from the source tree. I’d be happy to contribute a pull-request to that end in the x* projects that I use (xtl
,xsimd
,xtensor
andxtensor-python
), if there is interest.@tdegeus: I believe there are ways to specify the paths CMake uses for
find_package
and friends. So, technically, we could installxtensor
into some dedicated location and let CMake find them there. It’s just a separate build step (implying a separate configuration step which hopefully matches the project configuration), which feels kind of unnecessary for a header-only library.I very much agree with the sentiments @burnpanck has voiced. In my case, my company vendors all dependencies in git submodules. I don’t like it and I wished we used a real dependency management system like conan. But regardless of how I feel on the matter, or whether its a terrible idea or not, we aren’t going to redesign our entire build system and CI right now. Many people vendor dependencies via CMake’s
add_subdirectory
command, and although maybe a bad idea, its fairly standard practice. For this reason, having an interface target to link to that respectsadd_subdirectory
is something that will be a sticking point for a lot of people, myself included, in order to use this project.