0

I'm trying to build a git project I've cloned which use CMake for compilation and needs bison and flex. I'm using windows 10 and Clion IDE.

I've download Win flex-bison from https://sourceforge.net/projects/winflexbison/ but I can't understand how do I point the CMake to look in the win_flex_bison files I've downloaded.

at the moment the build fails on lines:

find_program(BISON_EXECUTABLE bison)

if(NOT EXISTS ${BISON_EXECUTABLE})
    message("Could not find bison executable.")
endif(NOT EXISTS ${BISON_EXECUTABLE})


find_program(FLEX_EXECUTABLE flex)

if(NOT EXISTS ${FLEX_EXECUTABLE})
        message("Could not find flex executable.")
endif(NOT EXISTS ${FLEX_EXECUTABLE})

IF (DEFINED FLEXLEXER_H_DIR)
  include_directories(${FLEXLEXER_H_DIR})
  message("Looking in ${CMAKE_REQUIRED_INCLUDES} for FlexLexer.h")
ELSE()

CHECK_INCLUDE_FILE_CXX("FlexLexer.h" HAVE_FLEXLEXER_H)
IF(NOT HAVE_FLEXLEXER_H)
  UNSET(HAVE_FLEXLER_H CACHE)
  message( FATAL_ERROR "Cannot find FlexLexer.h.  Set FLEXLEXER_H_DIR to point to where it is to be found.." )
ENDIF()

that massages I'm getting are:

Could not find bison executable.
Could not find flex executable.
-- Looking for C++ include FlexLexer.h
-- Looking for C++ include FlexLexer.h - not found
CMake Error at VALfiles/parsing/CMakeLists.txt:28 (message):
  Cannot find FlexLexer.h.  Set FLEXLEXER_H_DIR to point to where it is to be
  found..

-- Configuring incomplete, errors occurred!
  • "build fails" is too vague description. Please, show (add to the question post) **exact** error messages you got. – Tsyvarev Oct 27 '20 at 09:24
  • The second problem is a matter of making sure your `%PATH%` is contains those binaries. The first can be solved by setting `CMAKE_REQUIRED_INCLUDES` – Botje Oct 27 '20 at 09:44
  • I've added C:\GnuWin32\win_flex_bison-latest which is where the win_bison.exe and win_flex.exe are to %path%. still no good. – Oded Rozencweig Oct 27 '20 at 18:40

1 Answers1

0

You should use the following commands to find FLEX and BISON in CMake:

find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)

More information on FLEX and BISON gives you all you need to know.

hechth
  • 95
  • 11
  • tried and getting massages: -- Could NOT find BISON (missing: BISON_EXECUTABLE) -- Could NOT find FLEX (missing: FLEX_EXECUTABLE) . how do I tell CMake where to look for the packages? (which i put in 'C:\GnuWin32\win_flex_bison-latest') – Oded Rozencweig Oct 27 '20 at 15:56
  • You can set FLEX_ROOT or BISON_ROOT to those folders. Otherwise there should be variables in CMake which could be set to those folders. Is this your first CMake based project or your first time using CMake? Are you using the GUI tool? – hechth Oct 27 '20 at 20:22
  • yes, this is my first time using CMake. actually, it's my first c++ project in a while (usually use python). I didn't use the GUI tool, I tried the build using the CMakeLists.txt which existed in the git project. – Oded Rozencweig Oct 29 '20 at 08:14
  • Try using the GUI tool from CMake, it is very helpful in these things. It also allows you to set paths interactively. – hechth Oct 29 '20 at 08:44