In a previous question I asked for help with finding Flex. Following the advice given, I was able to find it and work with it. The version of Flex found was in my C:\Cygwin\bin directory.
For various reasons not to do with CMake, that version of Flex turns out not to be suitable, so I have installed win_flex instead. However, I am having difficulty getting CMake to find it - it seems like whatever I do, it still finds the Cygwin version instead.
I have win_flex.exe installed, and its directory is the first item in my system path.
I read in the manual that setting CMAKE_IGNORE_PATH doesn’t work with find_package (unless it’s in config mode, but FindFLEX.cmake is in /modules), so I’m using find_program.
Currently, I have the following code:
In my CMake command line:
-DCYGWIN_INSTALL_PATH=
In my actual script:
set(required_flex_version 2.5.35) # N.B. win_flex is version 2.6.4
if (MSVC)
set(CMAKE_IGNORE_PATH "C:/cygwin/bin") # I've also tried "C:\\cygwin\\bin")
message("Looking specifically for win_flex")
message("CMAKE_FIND_ROOT_PATH is ${CMAKE_FIND_ROOT_PATH}")
set(FLEX_EXECUTABLE )
find_program(FLEX_EXECUTABLE NAMES win_flex DOC "path to the flex executable")
message("win_flex found at ${FLEX_EXECUTABLE}")
else()
find_package(FLEX ${required_flex_version})
endif()
My output:
Looking specifically for win_flex
CMAKE_FIND_ROOT_PATH is
win_flex found at C:/cygwin/bin/flex.exe
How does one make sense of this?