Skip to content

Commit

Permalink
cmake/add_module: add GRAMMAR_DEPENDS argument
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <[email protected]>
  • Loading branch information
alltilla committed Dec 5, 2024
1 parent 692d484 commit d31ea5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions cmake/Modules/GenerateYFromYm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ endfunction()

# This function is used by add_module
function(module_generate_y_from_ym FileWoExtSrc FileWoExtDst)
if (${ARGC} EQUAL 2)
if (${ARGC} EQUAL 2 OR ${ARGC} EQUAL 3)
set(DEPS ${PROJECT_SOURCE_DIR}/lib/cfg-grammar.y)

if (${ARGC} EQUAL 3)
set(DEPS ${DEPS} ${ARGV2})
endif()

add_custom_command (OUTPUT ${FileWoExtDst}.y
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/lib/merge-grammar.py ${FileWoExtSrc}.ym > ${FileWoExtDst}.y
DEPENDS ${PROJECT_SOURCE_DIR}/lib/cfg-grammar.y
DEPENDS ${DEPS}
${FileWoExtSrc}.ym)
else()
message(SEND_ERROR "Wrong usage of module_generate_y_from_ym() function")
Expand Down
4 changes: 2 additions & 2 deletions cmake/add_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ include(CMakeParseArguments)

function (add_module)

cmake_parse_arguments(ADD_MODULE "" "TARGET" "GRAMMAR;SOURCES;DEPENDS;INCLUDES;LIBRARY_TYPE;COMPILE_OPTIONS" ${ARGN})
cmake_parse_arguments(ADD_MODULE "" "TARGET" "GRAMMAR;GRAMMAR_DEPENDS;SOURCES;DEPENDS;INCLUDES;LIBRARY_TYPE;COMPILE_OPTIONS" ${ARGN})

if (ADD_MODULE_GRAMMAR)
module_generate_y_from_ym(${CMAKE_CURRENT_SOURCE_DIR}/${ADD_MODULE_GRAMMAR} ${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR})
module_generate_y_from_ym(${CMAKE_CURRENT_SOURCE_DIR}/${ADD_MODULE_GRAMMAR} ${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR} ${ADD_MODULE_GRAMMAR_DEPENDS})
bison_target(${ADD_MODULE_TARGET}Grammar}
${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR}.y
${CMAKE_CURRENT_BINARY_DIR}/${ADD_MODULE_GRAMMAR}.c
Expand Down

0 comments on commit d31ea5b

Please sign in to comment.