aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/bison.cmake
blob: 38d2b91ff9ea6c96147269b954c998b95891935d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function(target_bison_parser Tgt Scope)
  foreach(arg ${ARGN})
    get_filename_component(argPath ${arg} REALPATH)
    if (argPath MATCHES "${CMAKE_SOURCE_DIR}/.*")
      file(RELATIVE_PATH argRel ${CMAKE_CURRENT_SOURCE_DIR} ${argPath})
      string(REPLACE ".." "__" ArgInBindir ${argRel})
      set(ArgInBindir ${CMAKE_CURRENT_BINARY_DIR}/${ArgInBindir})
    else()
      set(ArgInBindir ${argPath})
    endif()
    get_filename_component(OutputBase ${arg} NAME_WLE)
    get_filename_component(OutputDir ${ArgInBindir} DIRECTORY)
    add_custom_command(
      OUTPUT ${OutputDir}/${OutputBase}.cpp ${OutputDir}/${OutputBase}.h
      COMMAND ${CMAKE_COMMAND} -E make_directory ${OutputDir}
      COMMAND ${CMAKE_COMMAND} -E env M4=${CMAKE_BINARY_DIR}/bin/m4/bin/m4 ${CMAKE_BINARY_DIR}/bin/bison/bin/bison ${BISON_FLAGS} -v --defines=${OutputDir}/${OutputBase}.h -o ${OutputDir}/${OutputBase}.cpp ${arg}
      DEPENDS ${arg}
    )
    target_sources(${Tgt} ${Scope} ${OutputDir}/${OutputBase}.cpp ${OutputDir}/${OutputBase}.h)
  endforeach()
endfunction()

function(target_flex_lexers Tgt)
endfunction()