aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/bison.cmake
blob: df444f031e13f473f369d802208f835ef6b363fe (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_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()