steveire added a comment.

FYI, CMake target property `INTERFACE_SOURCES` is designed to make this easy.

For each module you would generate a file containing

  extern volatile int ${MODULE_NAME}ModuleAnchorSource;
  static int LLVM_ATTRIBUTE_UNUSED ${MODULE_NAME}ModuleAnchorDestination =
      ${MODULE_NAME}ModuleAnchorSource;

and then put that generated file in the `INTERFACE_SOURCES` of each module.

  target_sources(${MODULE_NAME} INTERFACE ${THE_GENERATED_FILE}.cpp)

Then, you don't need to maintain it in C++ like this. It is DRY because the 
`target_link_libraries` entry for the library is what causes the symbol to be 
used.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55595/new/

https://reviews.llvm.org/D55595



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to