Skip to content

ExternalProject: Use -S and -B args to robustly set configure dirs

Previously, the build directory was not explicitly specified. Instead, the current working directory was assumed to be the build directory and the source directory was passed as a positional argument. However, if the source directory contained a CMakeCache.txt, it was treated as a binary directory instead. For the scenario where a project is built in-source and it calls ExternalProject_Add() with its own source directory but a different build directory (e.g. to build itself with a different set of configure arguments), this results in a build error.

Explicitly list both the source and build directories using the -S and -B options respectively. This unambiguously sets both, avoiding the above problem.

Fixes: #24081 (closed)

Merge request reports