$<COMPILE_LANG_AND_ID:lang,id> may not be used with file(GENERATE) -- breaks some existing CMakeLists
Various bits of CMake in-the-wild write out files -- often pkg-config files -- that contain generator expressions in the variables substituted into the files. Sometimes that uses one stage (a single `configure_file()` or `file(GENERATE)`) and sometimes two (a `configure_file()` to substitute in variables, and a `file(GENERATE)` to do expansion). This fails with a message like this: ``` CMake Error at cmake/Modules/GeneratePkgConfig.cmake:181 (file): Error evaluating generator expression: $<COMPILE_LANG_AND_ID:CUDA,NVIDIA> $<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to specify include directories, compile definitions, and compile options. It may not be used with the add_custom_command, add_custom_target, or file(GENERATE) commands. Call Stack (most recent call first): CMakeLists.txt:747 (generate_and_install_pkg_config_file) ``` This affects: - libtorrent (https://github.com/arvidn/libtorrent/) - folly (https://github.com/facebook/folly/) I've filed an upstream (?) issue https://github.com/facebook/folly/issues/1414 as well. I see that in 3.17.2, COMPILE_LANG_AND_ID already existed with the same restrictions, so the "new" thing is, that it is leaking into compiler flags that existing projects were writing to pkg-config files.
issue