But from within the project, GLFW_BUILD_X11 is reported as ON. The docs do not completely make it clear to me this is how CMAKE_ARGS is supposed to be used. Did I get this right? Why is camke not setting GLFW_BUILD_X11 to OFF when building glfw?
The <contentOptions> can be any of the download, update, or patch options that the ExternalProject_Add() command understands. The configure, build, install, and test steps are explicitly disabled, so options related to those steps will be ignored.
The CMAKE_ARGS keyword relates to the configure step and is therefore ignored. If you want variables like GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 set to particular values when glfw is added to the main project, you need to set them in the main project before the call to FetchContent_MakeAvailable(glfw). Also note that even if you do that, if something else in the build has already added glfw to the build (by calling FetchContent_MakeAvailable(glfw) earlier), setting those variables will have no effect. Depending on the project, you might or might not have full control over when FetchContent_MakeAvailable(glfw) is called first.
But as of cmake 3.30, the single arg FetchContent_Populate has been deprecated, instead asking me to use FetchContent_Declare.
How am I to set cmake configure args for this? As classic workflows (that I had to scrape off the internet, and not present in the docs) does not work anymore
CMAKE_ARGS has never been supported for any version of FetchContent. Regardless of whether you were using FetchContent_Populate() or FetchContent_MakeAvailable(), the configure step has never been invoked by the sub-build. Whatever you were expecting CMAKE_ARGS to do, it wasn’t having any effect and at best was being silently ignored (and continues to be).
How am I to set cmake configure args for this?
I explained what you need to do in my previous reply. It would look something like this (with the caveats as noted in that previous reply):
Can I set cmake general options such as CMAKE_BUILD_TYPE and CMAKE_CXX_FLAGS too? Would they apply only to glfw, in this example, or for the whole project?