ExternalProject_Add - STAMP_DIR and LOG_DIR relative to PROJECT_BINARY_DIR / Missing possibility to use all `<PLACEHOLDERS>`
I would like to change the directories <STAMP_DIR>
and <LOG_DIR>
. Setting a new value makes ExternalProject_Add
interpret the path segment (not an absolute path) to be relative to the PROJECT_BINARY_DIR
instead of the default <STAMP_DIR>
or <LOG_DIR>
, which seems wrong to me. If that behavior was wanted one would simply prepend ${PROJECT_BINARY_DIR}
to specify an absolute path.
Also, it is already possible to use the placeholders <TMP_DIR>
, <DOWNLOAD_DIR>
, <SOURCE_DIR>
, <BINARY_DIR>
, <INSTALL_DIR>
and <LOG_DIR>
, though it is not possible to use the placeholders <STAMP_DIR>
, <NAME>
, <name>
, <base>
, <PREFIX>
, <EP_BASE>
and <EP_PREFIX>
. How comes? I think it would be convenient and conclusive.
Here is an excerpt of my code to show what I am struggling with:
include( ExternalProject )
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# SETTING A VARIABLE WITH THE NAME, SINCE THE PLACEHOLDER <NAME> CANNOT BE USED.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
set(EP_NAME "boost")
# Add boost as an external project.
ExternalProject_Add(${EP_NAME}
# -------------------------------------------------------------------------------
# Override the <STAMP_DIR>, to enable builds in multiple versions!
# -------------------------------------------------------------------------------
# Once boost has been built for any address-model (32bit/64bit) for any compiler
# (msvc, gcc, etc.), it won't be build again for any other address-model or
# compiler, because it says in the <STAMP_DIR>, that boost has already been
# built. To prevent that behavior, the stamp dir is put into a subfolder
# containing the TARGET_ARCHITECTURE and COMPILER_NAME.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Folders set relative to ${PROJECT_BINARY_DIR} instead of being appended to the
# default <STAMP_DIR> (<base>/Stamp/<name> or <prefix>/src/<name>-stamp) and the
# default <LOG_DIR>.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# STAMP_DIR ${TARGET_ARCHITECTURE}/${COMPILER_NAME}
# LOG_DIR logs
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# NONE OF THE FOLLOWING LINES WORK!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# STAMP_DIR <STAMP_DIR>/<NAME>/${TARGET_ARCHITECTURE}/${COMPILER_NAME}
# STAMP_DIR <EP_BASE>/Stamp/<NAME>/${TARGET_ARCHITECTURE}/${COMPILER_NAME}
# LOG_DIR <STAMP_DIR>/logs
# LOG_DIR <EP_BASE>/Stamp/<NAME>/${TARGET_ARCHITECTURE}/${COMPILER_NAME}/logs
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# This does work, since I set the used variables. But it seems unnecessarily complicated,
# since some of the information should already be available to ExternalProject_Add.
STAMP_DIR ${CMAKE_EP_BASE_PATH}/Stamp/${EP_NAME}/${TARGET_ARCHITECTURE}/${COMPILER_NAME}
# Putting the log files in a subfolder called 'logs' within <STAMP_DIR>.
LOG_DIR ${CMAKE_EP_BASE_PATH}/Stamp/${EP_NAME}/${TARGET_ARCHITECTURE}/${COMPILER_NAME}/logs
URL ${boost_URL}
URL_HASH SHA256=${boost_SHA1}
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Some <PLACEHOLDERS> are interpreted correctly, some not.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
CONFIGURE_COMMAND echo "TMP_DIR '<TMP_DIR>'" # OK
COMMAND echo "STAMP_DIR '<STAMP_DIR>'" # <STAMP_DIR>
COMMAND echo "DOWNLOAD_DIR '<DOWNLOAD_DIR>'" # OK
COMMAND echo "SOURCE_DIR '<SOURCE_DIR>'" # OK
COMMAND echo "BINARY_DIR '<BINARY_DIR>'" # OK
COMMAND echo "INSTALL_DIR '<INSTALL_DIR>'" # OK
COMMAND echo "LOG_DIR '<LOG_DIR>'" # OK
COMMAND echo "NAME '<NAME>'" # <NAME>
COMMAND echo "name '<name>'" # <name>
COMMAND echo "base '<base>'" # <base>
COMMAND echo "PREFIX '<PREFIX>'" # <PREFIX>
COMMAND echo "EP_BASE '<EP_BASE>'" # <EP_BASE>
COMMAND echo "EP_PREFIX '<EP_PREFIX>'" # <EP_PREFIX>
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
Tested on Windows 10 with cmake version 3.17.0.