It's not possible to build recurrent ExternalProject in source tree.
The attached project uses own source tree as SOURCE_DIR
for the internal ExternalProject_Add call. Project is built well out-of-source tree, but building it in-source tree leads to an issue. The generated ninja rule for the cmake command line of the external project looks as follows:
cd <BINARY_DIR> && cmake <CMAKE_ARGS> <SOURCE_DIR>
The above command works well when building out-of-source tree because SOURCE_DIR
doesn't contain CMakeCache.txt, but with in-source tree CMakeCache.txt is created by the users cmake call already and the SOURCE_DIR
from the above command contains CMakeCache.txt, so the configure command line of the external project behaves differently.
The obvious solution in this case is to replace the standard configure command by something more explicit, like:
ExternalProject_Add("myapp_ext"
SOURCE_DIR "${CMAKE_SOURCE_DIR}"
BINARY_DIR "${CMAKE_BINARY_DIR}/external_project"
CONFIGURE_COMMAND
"${CMAKE_COMMAND}"
"-G${CMAKE_GENERATOR}"
"-B" "${CMAKE_BINARY_DIR}/external_project"
"-S" "${CMAKE_SOURCE_DIR}"
)
It would be good for the ExternalProject module to use the same syntax implicitly, when generating a configure command line for the external projects.