Libeval: Use add_custom_target so grammar.c won't be cleaned

If you use add_custom_command to generate the grammar file,
it can be removed by "make clean". This then means the user will
need to get it back from Git, or regenerate it with Lemon.

Changing to add_custom_command removes the output file
from the clean list. The incantation to rebuild the grammar
remains the same: "make libeval_grammar", and it is still not
required to have lemon installed for a normal build.

Fixes: lp:1809610
* https://bugs.launchpad.net/kicad/+bug/1809610
This commit is contained in:
John Beard 2018-12-23 21:18:15 +00:00 committed by Seth Hillbrand
parent eb06ae5910
commit 5e705347bb
1 changed files with 3 additions and 8 deletions

View File

@ -24,20 +24,15 @@ find_program(LEMON lemon)
if( LEMON ) if( LEMON )
macro( generate_lemon_grammar GRAMMAR_LEMON GRAMMAR_C ) macro( generate_lemon_grammar TGT_NAME GRAMMAR_LEMON GRAMMAR_C )
add_custom_command( add_custom_target( ${TGT_NAME}
DEPENDS ${GRAMMAR_LEMON} DEPENDS ${GRAMMAR_LEMON}
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${GRAMMAR_C}
COMMAND ${LEMON} -q ${GRAMMAR_LEMON} COMMAND ${LEMON} -q ${GRAMMAR_LEMON}
COMMENT "Running Lemon on ${GRAMMAR_LEMON} -> ${GRAMMAR_C}" COMMENT "Running Lemon on ${GRAMMAR_LEMON} -> ${GRAMMAR_C}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
) )
endmacro() endmacro()
generate_lemon_grammar( grammar.lemon grammar.c ) generate_lemon_grammar( libeval_grammar grammar.lemon grammar.c )
add_custom_target(libeval_grammar
DEPENDS grammar.c
)
endif() endif()