aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/bison.cmake
blob: 440d86ffed4149f7b4bd962b681790963adc054a (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
function(target_bison_parser Tgt Scope)
  foreach(arg ${ARGN})
    file(REAL_PATH ${arg} argPath)
    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_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()