CMake fails to evaluate nested generator expressions in ExternalProject_Add(Boost)
I'm trying to build Boost as an external project using the following CMakeLists.txt. I'm considering using the PLATFORM_ID generator expression to enable different build parameters depending on the target platform.
EDIT: I should note that I'm not confident my current Android parameters will work, but I'm focusing on the Generator Expression at the moment. If I can get the generator expression working, I could also consider compiling Boost on Windows - something like CONFIGURE_COMMAND $<$<PLATFORM_ID:Windows>:<SOURCE_DIR>/bootstrap.bat ...>
cmake_minimum_required(VERSION 3.13)
include(ExternalProject)
set(installDir ${CMAKE_CURRENT_BINARY_DIR}/install)
set(BOOST_BUILD_DIR <SOURCE_DIR>/../boost-build)
ExternalProject_Add(boost
URL https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2
URL_HASH SHA256=7f6130bc3cf65f56a618888ce9d5ea704fa10b462be126ad053e80e553d6d8b7
INSTALL_DIR ${installDir}
BUILD_IN_SOURCE TRUE
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E time <SOURCE_DIR>/bootstrap.sh --with-libraries=filesystem,program_options,regex
COMMAND ${CMAKE_COMMAND} -E make_directory ${BOOST_BUILD_DIR}
BUILD_COMMAND $<$<PLATFORM_ID:Linux>:${CMAKE_COMMAND} -E time <SOURCE_DIR>/b2 --prefix=<INSTALL_DIR> --build-dir=${BOOST_BUILD_DIR} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} variant=release link=static cxxflags=-fPIC cxxstd=14 install>
COMMAND $<$<PLATFORM_ID:Android>:${CMAKE_COMMAND} -E time <SOURCE_DIR>/b2 --without-python --abbreviate-paths -d2 --debug-configuration --prefix=<INSTALL_DIR> --build-dir=${BOOST_BUILD_DIR} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} architecture=arm address-model=32 binary-format=elf abi=aapcs target-os=android variant=release link=static cxxflags=-fPIC cxxstd=14 install>
INSTALL_COMMAND ""
)
Unfortunately, when I get to the build step, I receive the following error:
[ 75%] Performing build step for 'boost'
/bin/sh: 1: $<1:/opt/cmake-3.13.1-Linux-x86_64/bin/cmake: not found
CMakeFiles/boost.dir/build.make:114: recipe for target 'boost-prefix/src/boost-stamp/boost-build' failed
make[2]: *** [boost-prefix/src/boost-stamp/boost-build] Error 127
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/boost.dir/all' failed
make[1]: *** [CMakeFiles/boost.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
As a workaround, I intend to use variables and an if/elseif/else to achieve the intended effect, but I was wondering why this generator expression failed.