Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex/Bison targets does not exist

Tags:

cmake

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 directory leafc:

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 to 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!

The files are there:

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

So what did I do wrong?

like image 349
Lanbo Avatar asked Oct 09 '22 08:10

Lanbo


1 Answers

It seems you just got the arguments to ADD_FLEX_BISON_DEPENDENCY mixed up. Try:

ADD_FLEX_BISON_DEPENDENCY(LeafScanner LeafParser)

Furthermore there is a typo in your FLEX_TARGET call (CMAKE_CURRENT_BIANRY_DIR).

like image 180
sakra Avatar answered Oct 13 '22 11:10

sakra