How to write a new generator?

Just taking a glance, it doesn’t look to me like Please is suitable backend. However, it’s only at a glance and you’ve not provided details into how you expect it to work, so feel free to correct me.

CMake has its own model of what targets are and how they interact. There’s almost certainly not a way to put something like this into a generated Please file other than as a series of commands to perform (i.e., c_library and cc_library are not usable in general):

add_library(foo STATIC
  foo.c
  bar.c
  impl.cxx # C++ code
  fort.f90 # some Fortran source code
)
target_link_library(foo
  PRIVATE
    Some::Target # has complicated genex requirements
)

As for the question you asked:

  • local generators represent a build directory added by add_subdirectory and are “homes” for targets
  • the global generator coordinates all of the local generators to store global information and the like