ExternalProject uses cmd on windows instead of parent shell
If the parent cmake is launched by an MSYS2 shell, the ExternalProject_Add
function uses cmd instead of the parent shell to launch its commands:
include(ExternalProject)
ExternalProject_Add(libbacktrace
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ../libbacktrace/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
BUILD_COMMAND make
INSTALL_COMMAND make install
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/lib/libbacktrace.a"
# INSTALL_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/lib/libbacktrace.a"
)
will result in:
[80/435] Performing configure step for 'libbacktrace'
FAILED: _deps/fbbe_stacktrace-build/libbacktrace/src/libbacktrace-stamp/libbacktrace-configure C:/Users/Febbe/workspace/xournalpp/build-ucrt/_deps/fbbe_stacktrace-build/libbacktrace/src/libbacktrace-stamp/libbacktrace-configure
cmd.exe /C "cd /D C:\Users\Febbe\workspace\xournalpp\build-ucrt\_deps\fbbe_stacktrace-build\libbacktrace\src\libbacktrace-build && ..\libbacktrace\configure --prefix=C:/Users/Febbe/workspace/xournalpp/build-ucrt/_deps/fbbe_stacktrace-build/libbacktrace && C:\msys64\ucrt64\bin\cmake.exe -E touch C:/Users/Febbe/workspace/xournalpp/build-ucrt/_deps/fbbe_stacktrace-build/libbacktrace/src/libbacktrace-stamp/libbacktrace-configure"
Der Befehl "..\libbacktrace\configure" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
ninja: build stopped: subcommand failed.
Beside the fact, that autotools configure file is nonsense to Microsoft's cmd, all targets should be build and configured etc. in the domain of the parent shell. This will also be an issue for e.g. custom batch scripts, which set up an environment. The environment is cleared afterward, and the configured and build target now has random and possible incompatible dependencies.