How do angle-brackets varaibles get expanded (e.g. <LINK_FLAGS>)? Can you add new ones?

Hello everybody,

This is yet another followup to Need CMake M Plugin help: Single target, Single source, multiple objects, multiples libraries.

Lots of thinking makes me convinced that the solution cannot be provided by CMake natively, but I think I can cajole CMake into doing the right thing. I can do it by providing a macro that will create 2 targets with different compilation “flags”. I say “flags”, but our compiler doesn’t really use flags, but rather environment variables, but that’s not an issue as I can achieve the same effect. My question is how can I make the targets take different compilation flags?

The two targets need to be compiled differently as follows:

1. ydb_chset="utf-8" $ydb_dist/yottadb <SOURCE>
2. ydb_chset="M" $ydb_dist/yottadb <SOURCE>

This is my current CMake Plugin compiler rule:

(CMAKE_M_COMPILE_OBJECT "LC_ALL=\"${LC_ALL}\" ydb_chset=\"${ydb_chset}\" ydb_icu_version=\"${icu_version}\" <CMAKE_M_COMPILER> -object=<OBJECT>")

I was reading the CMake source code and some example modules. I saw this example:

  set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")

Therefore, ideally, I would like my build system to be able to specify the angle bracket variable per target, which would accomplish what I want. So the question is:

  1. How does CMake determine what the angle bracket variables are? Can you set them per target?
  2. Can you define new angle bracket variables?


They’re internal things to the generators (namely the non-IDE generators; I don’t think the IDEs use these templates).

Not without editing CMake’s source itself. I think this will need some new logic in CMake to support these compilers.

Cc: @brad.king