CMake ExternalProject addon forcing install path to c:/program files and ignoring INSTALL_PATH option

This is incredibly confusing. I have the following CMake code in my CMakeLists.txt:

list(APPEND CMAKE_ARGS "-DSCRIPT_API=C#" "-DBSF_ENABLE_EXCEPTIONS=On" "-DAUDIO_MODULE=OpenAudio" "-DBSF_PLUGIN_IMGUI=Off" "-DRENDER_API_MODULE=Vulkan" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
ExternalProject_Add(
bsf
PREFIX "deps"
TMP_DIR "deps/tmp/bsf"
STAMP_DIR "deps/stamps/bsf"
LOG_DIR "deps/logs/bsf"
DOWNLOAD_DIR "deps/downloads/bsf"
SOURCE_DIR "deps/sources/bsf"
INSTALL_DIR "deps/install/bsf"
GIT_REPOSITORY "https://github.com/GameFoundry/bsf"
GIT_PROGRESS true
SOURCE_SUBDIR ""
BUILD_ALWAYS true
CMAKE_ARGS ${CMAKE_ARGS}
LOG_CONFIGURE true
LOG_DOWNLOAD true
LOG_UPDATE true
LOG_PATCH true
LOG_BUILD true
LOG_INSTALL true
LOG_TEST true
LOG_OUTPUT_ON_FAILURE true
BINARY_DIR "deps/bin"
)

Yet for some reason CMake is forcing the install path to c:\program files\bsf. It does this with everything else I try including this way and its downright irritating. Is there a way to get the expected behavior?

1 Like

OK, so to fix this problem I had to explicitly define CMAKE_INSTALL_PREFIX in CMAKE_ARGS.

Defining CMAKE_INSTALL_PREFIX in CMAKE_ARGS is the intended way to do this.

The ExternalProject documentation for INSTALL_DIR states:

… This does not actually configure the external project to install to the given prefix. That must be done by passing appropriate arguments to the external project configuration step