I’m struggling a bit with ExternalProject and multi-config generators (MSVC).
How do I “tell” ExternalProject_Add() whether I need a debug or a release build depending on the currently selected build type ?
The external project has nmake Makefiles.
In addition to a -DCMAKE_BUILD_TYPE:STRING=$<CONFIG>, you’ll likely also want BUILD_DIR something/$<CONFIG> STAMP_DIR/something/$<CONFIG> or the like to avoid rebuilds on every configuration switch. The install tree may also get very confused if the contents of files overlap in ways that are configuration-sensitive (e.g., not changing library names).
I would have expected the ExternalProject to follow the same config used to build the main project. Is that not happening for you, or are you trying to force a particular config different to the main build? When the main project is using a multi-config generator, the ExternalProject module explicitly passes the config to use as --config $<CONFIG> on the cmake --build ... command line it constructs.