FetchContent_MakeAvailable could not find header generated by configure_file

I am trying to add a lib called taco to my own project. I use cmake’s FetchContent to add it:

FetchContent_Declare(
 taco
 GIT_REPOSITORY https://github.com/tensor-compiler/taco.git
 GIT_TAG master
)
FetchContent_MakeAvailable(taco)

Then I got the following error during compilation:

_deps/taco-src/tools/taco.cpp:35:10: fatal error: taco/version.h: No such file or directory
   35 | #include "taco/version.h"

version.h is generated by configure_file and is in _deps/taco-build/include/taco/. However, in taco’s tools/CMakeList.txt, the include searching path is set to “${CMAKE_BINARY_DIR}/include”. The compilation error is cause by the fact that ${CMAKE_BINARY_DIR} is the binary folder of my project instead of _deps/taco-build generated by FetchContent.

Now, what I did is manually replacing CMAKE_BINARY_DIR by _deps/taco-build after a failed cmake run and I am looking for a better solution.

Thank you!

taco doesn’t seem ready to be vendored like this. It should probably use CMAKE_CURRENT_BINARY_DIR instead.