Append variable to <BUILD_DIR> in ExternalProject_Add command

I’ve been experimenting with getting a reliable cross-platform ExternalProject_Add command to work and have now got something that looks like this…

ExternalProject_Add(
    SDL2
    URL https://www.libsdl.org/release/SDL2-2.0.12.tar.gz
    URL_HASH MD5=783b6f2df8ff02b19bb5ce492b99c8ff
    CMAKE_GENERATOR Ninja
    BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/SDL2/build/${CMAKE_BUILD_TYPE}
    INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
    CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
               -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})

The reason for setting the CMAKE_GENERATOR explicitly to Ninja is so I can get consistent behaviour across Windows and macOS (the differences between single and multi-config generators I’ve found complicated things…).

It does feel like there should be an easier way to do this though, ideally all I would like to write is this:

ExternalProject_Add(
    SDL2
    URL https://www.libsdl.org/release/SDL2-2.0.12.tar.gz
    URL_HASH MD5=783b6f2df8ff02b19bb5ce492b99c8ff
    INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
    CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>)

And then externally build both Debug and Release and ideally have the build artefacts wind up in separate folders. It feels like this must be a common pattern, I just feel like I must be missing something.

Any suggestions on how to improve this solution would be greatly appreciated,

Thanks!

Tom