| 1 |
# The cxx.bnf grammar file |
| 2 |
set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf) |
| 3 |
|
| 4 |
setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target) |
| 5 |
|
| 6 |
# Generate inc files. |
| 7 |
set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc) |
| 8 |
add_custom_command(OUTPUT ${cxx_symbols_inc} |
| 9 |
COMMAND "${pseudo_gen}" |
| 10 |
--grammar ${cxx_bnf} |
| 11 |
--emit-symbol-list |
| 12 |
-o ${cxx_symbols_inc} |
| 13 |
COMMENT "Generating nonterminal symbol file for cxx grammar..." |
| 14 |
DEPENDS ${pseudo_gen_target} ${cxx_bnf} |
| 15 |
VERBATIM) |
| 16 |
|
| 17 |
set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc) |
| 18 |
add_custom_command(OUTPUT ${cxx_bnf_inc} |
| 19 |
COMMAND "${pseudo_gen}" |
| 20 |
--grammar ${cxx_bnf} |
| 21 |
--emit-grammar-content |
| 22 |
-o ${cxx_bnf_inc} |
| 23 |
COMMENT "Generating bnf string file for cxx grammar..." |
| 24 |
DEPENDS ${pseudo_gen_target} ${cxx_bnf} |
| 25 |
VERBATIM) |
| 26 |
|
| 27 |
# add_custom_command does not create a new target, we need to deine a target |
| 28 |
# explicitly, so that other targets can depend on it. |
| 29 |
add_custom_target(cxx_gen |
| 30 |
DEPENDS ${cxx_symbols_inc} ${cxx_bnf_inc} |
| 31 |
VERBATIM) |