mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[CMAKE] Introduce a way to use auto generation using bison and flex. Dedicated to Eric Kohl. CORE-10055
svn path=/trunk/; revision=68840
This commit is contained in:
parent
6c6dae8b30
commit
17228d9d3e
2 changed files with 30 additions and 0 deletions
|
@ -75,6 +75,9 @@ if(NOT MSVC_IDE)
|
||||||
unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
|
unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Bison and Flex support
|
||||||
|
# include(cmake/bison-flex.cmake)
|
||||||
|
|
||||||
if(NOT CMAKE_CROSSCOMPILING)
|
if(NOT CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
add_definitions(-DTARGET_${ARCH})
|
add_definitions(-DTARGET_${ARCH})
|
||||||
|
|
27
reactos/cmake/bison-flex.cmake
Normal file
27
reactos/cmake/bison-flex.cmake
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
# Simply use :
|
||||||
|
# add_bison_files(foo.y)
|
||||||
|
# and
|
||||||
|
# add_flex_files(foo.l)
|
||||||
|
# then add ${CMAKE_CURRENT_BINARY_DIR}/foo.tab.c
|
||||||
|
# and ${CMAKE_CURRENT_BINARY_DIR}/foo.yy.c to the source list
|
||||||
|
|
||||||
|
function(add_bison_files)
|
||||||
|
foreach(_file ${ARGN})
|
||||||
|
get_filename_component(_name ${_file} NAME_WE)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.tab.c ${CMAKE_CURRENT_BINARY_DIR}/${_name}.tab.h
|
||||||
|
COMMAND bison -p ${_name}_ -o ${CMAKE_CURRENT_BINARY_DIR}/${_name}.tab.c --defines=${CMAKE_CURRENT_BINARY_DIR}/${_name}.tab.h ${CMAKE_CURRENT_SOURCE_DIR}/${_file}
|
||||||
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(add_flex_files)
|
||||||
|
foreach(_file ${ARGN})
|
||||||
|
get_filename_component(_name ${_file} NAME_WE)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.yy.c ${CMAKE_CURRENT_BINARY_DIR}/${_name}.yy.h
|
||||||
|
COMMAND flex -o ${CMAKE_CURRENT_BINARY_DIR}/${_name}.yy.c --header-file=${CMAKE_CURRENT_BINARY_DIR}/${_name}.yy.h ${CMAKE_CURRENT_SOURCE_DIR}/${_file}
|
||||||
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
Loading…
Reference in a new issue