Custom source-to-source translator language support
As shown within Modules/CMakeAddNewLanguage.txt
, it's possible to use an internal API to add a custom language such that enable_language(MYLANG)
works. Unfortunately, a new language always requires creation of an object file. It doesn't allow situations where Foo.mylang
gets preprocessed into Foo.cpp
, Foo.h
, or similar. For those, you're still required to do add_custom_target
, and put the generated file names into the add_executable
call. Though this can be avoided with functions such as cuda_add_executable
, this doesn't scale or allow you to use multiple preprocessors.
The only issue would be if the preprocessor requires extra arguments in order to create the resulting code, but I see SWIG uses set(CMAKE_MYLANG_FLAGS "-bla")
and source file properties for situations like that.