# How I get bison/flex on Windows

**URL:** <https://discourse.cmake.org/t/how-i-get-bison-flex-on-windows/13505>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [January 28, 2025, 10:40pm UTC](https://discourse.cmake.org/t/how-i-get-bison-flex-on-windows/13505 "2025-01-28T22:40:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LegalizeAdulthood](https://discourse.cmake.org/user_avatar/discourse.cmake.org/legalizeadulthood/32/5282_2.png) [@LegalizeAdulthood](https://discourse.cmake.org/u/LegalizeAdulthood)\
**Post date:** [January 28, 2025, 10:40pm UTC](https://discourse.cmake.org/t/how-i-get-bison-flex-on-windows/13505/1 "2025-01-28T22:40:52Z")

</div>

Having code that depends on bison/flex has always been a bit of a PITA on Windows because you have to manually go get the dependency, install it somewhere and then make sure that all your builds have that location in your PATH in order for `find_package(BISON)` to work.

Recently, I came up with this recipe that made my life easier; maybe it will help you too.

```auto
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
    include(FetchContent)
    FetchContent_Declare(download_bison
        URL "https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip"
        URL_MD5 "720226b1befe7033fb3ecc98f5ffd425"
        DOWNLOAD_EXTRACT_TIMESTAMP FALSE)
    FetchContent_MakeAvailable(download_bison)
    set(BISON_ROOT "${download_bison_SOURCE_DIR}")
    message(STATUS "BISON_ROOT=${BISON_ROOT}")
endif()
find_package(BISON REQUIRED)

```

…now I don’t need any manual steps for the Windows build to work in CI or for new developers cloning [my project](https://github.com/LegalizeAdulthood/trn).
