Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » CMake question about find_package (WIndows)

This thread is locked; no one can reply to it. rss feed Print
CMake question about find_package (WIndows)
ZoriaRPG
Member #16,714
July 2017
avatar

Right now, in our CMakeLists, we have a simple call to find flex and bison:

find_package(BISON QUIET)
find_package(FLEX QUIET)

The issue here, is, that if CMake is building for MSVC, I want it to use a specific (provided) version of flex-bison.

I tried a variety of permutations to find_package, but I keep coming up empty.

The files are:

./winflex/win-flex.exe
and
./winflex/win-bison.exe

Do I need to make modules to load these? Hoe exactly can I sub out those calls to load these specific files if(MSVC) ?

#SelectExpand
1############################################################# 2# Build the ZScript parser 3############################################################# 4 5find_package(BISON QUIET) 6find_package(FLEX QUIET) 7 8if(${BISON_FOUND} AND ${FLEX_FOUND} AND WANT_ZSCRIPT) 9 if(MSVC) 10 set(FLEXFLAGS "--wincompat") 11 endif() 12 FLEX_TARGET(ZScriptLexer ${CMAKE_SOURCE_DIR}/src/parser/ffscript.lpp ${CMAKE_SOURCE_DIR}/src/parser/lex.yy.cpp COMPILE_FLAGS ${FLEXFLAGS}) 13 BISON_TARGET(ZScriptParser ${CMAKE_SOURCE_DIR}/src/parser/ffscript.ypp ${CMAKE_SOURCE_DIR}/src/parser/y.tab.cpp) 14 add_flex_bison_dependency(ZScriptLexer ZScriptParser) 15else() 16 message(WARNING "Flex and Bison not found. ZQuest will be compiled without the ZScript parser.") 17 set(ZQUEST_ZSCRIPT_SOURCES ${ZQUEST_ZSCRIPT_SOURCES_NOPARSER}) 18endif()

The CMake docs absolutely suck, with no true examples and whatnot.

if I need a module, would someone please carefully explain WTF I need to do to ad it?

Source CMakeLists file is here:
https://github.com/ArmageddonGames/ZeldaClassic/blob/2.55/CMakeLists.txt

CMake Modules, here:
https://github.com/ArmageddonGames/ZeldaClassic/tree/2.55/modules

the reason that I am doing this, is that if a user has both MSVC and MinGW32 installed, then CMake finds the *nix flex and the *nix Bison first, and of course, if using MSVC to compile, those do not work.

I know only a bit about CMake and I could use some help on this one.

Many thanks. .

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Don't use the cmake docs, they do suck. Use the manual instead.

Basically what you have to do is set a build time variable that controls the call to flex and bison.

Here's a CHM version of the cmake manual. You'll wonder why you never used it before....

https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/downloads/CMake314rc4.chm

https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html

Go to: