bison.cmake 1.1 KB

123456789101112131415161718192021222324
  1. function(target_bison_parser Tgt Scope)
  2. foreach(arg ${ARGN})
  3. get_filename_component(argPath ${arg} REALPATH)
  4. if (argPath MATCHES "${CMAKE_SOURCE_DIR}/.*")
  5. file(RELATIVE_PATH argRel ${CMAKE_CURRENT_SOURCE_DIR} ${argPath})
  6. string(REPLACE ".." "__" ArgInBindir ${argRel})
  7. set(ArgInBindir ${CMAKE_CURRENT_BINARY_DIR}/${ArgInBindir})
  8. else()
  9. set(ArgInBindir ${argPath})
  10. endif()
  11. get_filename_component(OutputBase ${arg} NAME_WLE)
  12. get_filename_component(OutputDir ${ArgInBindir} DIRECTORY)
  13. add_custom_command(
  14. OUTPUT ${OutputDir}/${OutputBase}.cpp ${OutputDir}/${OutputBase}.h
  15. COMMAND ${CMAKE_COMMAND} -E make_directory ${OutputDir}
  16. 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}
  17. DEPENDS ${arg}
  18. )
  19. target_sources(${Tgt} ${Scope} ${OutputDir}/${OutputBase}.cpp ${OutputDir}/${OutputBase}.h)
  20. endforeach()
  21. endfunction()
  22. function(target_flex_lexers Tgt)
  23. endfunction()