ExternalProject_Add - Cannot set DOWNLOAD_NO_EXTRACT to 0/NO/OFF/FALSE
The value set for the DOWNLOAD_NO_EXTRACT property of an externally added project (ExternalProject_Add) is ignored. The mere existence of the property makes CMake skip extraction of the sources, regardless of its value, being set to e.g. 0/NO/OFF or FALSE.
Here is an excerpt of my code, which I hope is enough to understand the problem. Only the part with the exclamation marks should be of interest. I did not delete the other properties since maybe a combination of them or the order could be interesting for debugging purposes?!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Try to extract/skip the extraction depending on a variable.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Set a variable containing both the property and the value.
# This does not work at all. The value would be appended to the 'URL_HASH'.
set(boost_DOWNLOAD_NO_EXTRACT "DOWNLOAD_NO_EXTRACT true")
# Set a variable containing a boolean value.
#set(boost_DOWNLOAD_NO_EXTRACT_VALUE 0)
#set(boost_DOWNLOAD_NO_EXTRACT_VALUE NO)
#set(boost_DOWNLOAD_NO_EXTRACT_VALUE OFF)
set(boost_DOWNLOAD_NO_EXTRACT_VALUE FALSE)
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Add boost as an external project.
ExternalProject_Add(boost
# -------------------------------------------------------------------------------
# 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 the 'build'
# directory into a subfolder called stamp.
STAMP_DIR stamp
URL ${boost_URL}
URL_HASH SHA256=${boost_SHA1}
# Do not extract the sources, if they already exist.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# NONE OF THE FOLLOWING LINES WORK!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#${boost_DOWNLOAD_NO_EXTRACT}
DOWNLOAD_NO_EXTRACT ${boost_DOWNLOAD_NO_EXTRACT_VALUE}
#DOWNLOAD_NO_EXTRACT 0
#DOWNLOAD_NO_EXTRACT NO
#DOWNLOAD_NO_EXTRACT OFF
#DOWNLOAD_NO_EXTRACT FALSE
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Uncomment do debug the configure command.
#CONFIGURE_COMMAND echo "boost_CONFIGURE_COMMAND ==> ${boost_CONFIGURE_COMMAND}"
# COMMAND ${boost_CONFIGURE_COMMAND}
CONFIGURE_COMMAND ${boost_CONFIGURE_COMMAND}
# Uncomment do debug the build command.
#BUILD_COMMAND echo "boost_BUILD_COMMAND ==> ${boost_BUILD_COMMAND}"
# COMMAND ${boost_BUILD_COMMAND}
BUILD_COMMAND ${boost_BUILD_COMMAND}
INSTALL_COMMAND ""
# Force the external project to always be built.
# If it is built once in a e.g. 32bit version, a call to build it as 64bit
# will not be executed, since CMAKE thinks it is already build. Forcing the build
# solves this problem.
BUILD_ALWAYS true
# Do not set this true, as it would override the <SOURCE_DIR> to be equal to <BINARY_DIR>
BUILD_IN_SOURCE false
)
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Get the value
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ExternalProject_Get_Property(boost DOWNLOAD_NO_EXTRACT)
# Correctly prints the set value! But the value seems to be ignored! For example:
# -- DOWNLOAD_NO_EXTRACT="FALSE"
cmake_print_variables(DOWNLOAD_NO_EXTRACT)
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Tested on Windows 10 with CMake versions:
- cmake version 3.16.0-rc1
- cmake version 3.17.0