Reputation: 1295
I want to run the following command
win_bison.exe --output="calc.tab.cpp" --defines="calc.tab.h" "calc.y"
and then create an executable from the products of this command with CMake
add_executable(Calc calc.tab.cpp calc.tab.h)
All the files (win_bison.exe, calc.y) are found in the CMakeLists.txt
folder.
What is the correct way to do so? Please give the commands explanations.
Upvotes: 0
Views: 233
Reputation: 2339
If your project is indeed structured like that, then you can use the FindBison
CMake module
find_package(BISON)
BISON_TARGET(MyCalcParser calc.y
${CMAKE_CURRENT_BINARY_DIR}/calc.tab.cpp
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/calc.tab.h)
add_executable(Calc ${BISON_MyCalcParser_OUTPUTS})
Notes
find_package
searches by setting the BISON_DIR
variable in the command line invocation of CMake, i.e. -DBISON_DIR=[source dir]
, or you can place the Bison executable somwhere that is system-wide accessible/invocable.Upvotes: 0