Flex / Bison goals do not exist

I have a subdirectory structure in my project with two cmake files. One of them should be a compiler using flex and bison, but cmake gives me an error, I don't quite understand:

cmake_minimum_required(VERSION 2.8) project(leaf) add_subdirectory(leafc) 

and in the leafc directory:

 find_package(BISON) find_package(FLEX) BISON_TARGET(LeafParser ${CMAKE_CURRENT_SOURCE_DIR}/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp) FLEX_TARGET(LeafScanner ${CMAKE_CURRENT_SOURCE_DIR}/lexer.l ${CMAKE_CURRENT_BIANRY_DIR}/lexer.cpp) ADD_FLEX_BISON_DEPENDENCY(LeafParser LeafScanner) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable(leafc main.cpp ${BISON_LeafParser_OUTPUTS} ${FLEX_LeafScanner_OUTPUTS}) 

But I get this error when trying cmake .

 CMake Error at /usr/share/cmake-2.8/Modules/FindFLEX.cmake:132 (MESSAGE): Flex target `LeafParser' does not exists. Call Stack (most recent call first): leafc/CMakeLists.txt:6 (ADD_FLEX_BISON_DEPENDENCY) CMake Error at /usr/share/cmake-2.8/Modules/FindFLEX.cmake:136 (MESSAGE): Bison target `LeafScanner' does not exists. Call Stack (most recent call first): leafc/CMakeLists.txt:6 (ADD_FLEX_BISON_DEPENDENCY) CMake Error at /usr/share/cmake-2.8/Modules/FindFLEX.cmake:139 (SET_SOURCE_FILES_PROPERTIES): set_source_files_properties called with incorrect number of arguments. Call Stack (most recent call first): leafc/CMakeLists.txt:6 (ADD_FLEX_BISON_DEPENDENCY) -- Configuring incomplete, errors occurred! 

Files are:

 ├── CMakeLists.txt ├── leafc │  ├── CMakeLists.txt │  ├── lexer.l │  ├── main.cpp │  └── parser.y └── README 

So what have I done wrong?

+4
source share
1 answer

It seems you just messed up the arguments ADD_FLEX_BISON_DEPENDENCY . Try:

 ADD_FLEX_BISON_DEPENDENCY(LeafScanner LeafParser) 

In addition, there is a typo in your FLEX_TARGET call (CMAKE_CURRENT_ BIANRY _DIR).

+4
source

Source: https://habr.com/ru/post/1384271/


All Articles