Skip to content

cmake: require bison >= 2.5 and flex - #110

Open
Andrej730 wants to merge 3 commits into
chronoxor:mainfrom
Andrej730:cmake-bison-requirement
Open

Andrej730 wants to merge 3 commits into
chronoxor:mainfrom
Andrej730:cmake-bison-requirement

Conversation

@Andrej730

Copy link
Copy Markdown

Hi! Adding bison requirement to cmake to catch errors like #27 early, during configuration.

Either way, bison is already required, building without it breaks at configuration stage:

CMake Error at CMakeLists.txt:48 (bison_target):
  Unknown CMake command "bison_target".

With 2.5 REQUIRED it now will result in:

  Could NOT find BISON (missing: BISON_EXECUTABLE) (Required is at least
  version "2.5")

Or if bison is found (important on Mac, which is stuck on 2.3 and would break during the build with more obscure invalid option -- W):

  Could NOT find BISON: Found unsuitable version "2.3", but required is at
  least "2.5"

Why 2.5:

  • 2.3 - breaks with invalid option -- W
  • 2.4 - breaks with invalid argument no-conflicts-rr for --warnings
  • 2.5 - (at least) builds fine

@chronoxor can you please take a look?

@chronoxor

Copy link
Copy Markdown
Owner

Did you check this MacOS build in github, should work out of the box
https://github.com/chronoxor/FastBinaryEncoding/actions/runs/34533534842/job/103059696950

-- The System identification is Darwin 25.6.0 Platform/Darwin
-- Found BISON: /opt/homebrew/opt/bison/bin/bison (found version "3.8.2")
-- Found FLEX: /opt/homebrew/opt/flex/bin/flex (found version "2.6.4")

@Andrej730

Andrej730 commented Sep 27, 2026 •

Copy link
Copy Markdown
Author

Did you check this MacOS build in github, should work out of the box
chronoxor/FastBinaryEncoding/actions/runs/34533534842/job/103059696950

It works, because CI prefixes PATH. If user doesn't install bison from brew / install it without prefixing PATH, it will fallback to default Mac bison 2.3

- name: "Setup flex, bison"
run: |
brew install flex bison
echo "/opt/homebrew/opt/flex/bin:/opt/homebrew/opt/bison/bin" >> "$GITHUB_PATH"

Here's an example failing build using this commit e37a47f - https://github.com/Andrej730/FastBinaryEncoding/actions/runs/36319928061/job/108621678066

-- Found BISON: /usr/bin/bison (found version "2.3")
...
 /Applications/Xcode_26.6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison: invalid option -- W
Try `/Applications/Xcode_26.6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison --help' for more information.
make[2]: *** [/Users/runner/work/FastBinaryEncoding/FastBinaryEncoding/source/fbe-parser.cpp] Error 1
make[2]: *** Waiting for unfinished jobs....

@Andrej730 Andrej730 changed the title cmake: require bison >= 2.5 cmake: require bison >= 2.5 and flex Sep 27, 2026
@Andrej730

Andrej730 commented Sep 27, 2026 •

Copy link
Copy Markdown
Author

Since flex is also required, I've added similar change for flex, for consistency. So it will error now:

CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find FLEX (missing: FLEX_EXECUTABLE)

instead of

CMake Error at CMakeLists.txt:46 (flex_target):
  Unknown CMake command "flex_target"

In case flex is missing.

Unsure if there's any particular version requirement for flex, so the version is omitted.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants