[CMake] FindLua51.cmake

E. Wing ewmailing at gmail.com
Mon Jun 2 15:11:11 EDT 2008


> Why not LUA51_FOUND?
> Is this valid?
> I think not.
> Attached patch changes variable name LUA50_FOUND to LUA51_FOUND.

Yes, that looks like a bug. That FIND_PACKAGE_HANDLE_STANDARD_ARGS
stuff is new to me. Somebody else added it and must have done the
normal copy/paste thing/bug. I checked in the fix.

> PS:
> Even better may be single macro FindLua with version number instead of
> FindLua50/FindLua51.

This was a design decision on my part. Lua is a little unusual with
respect to version number schemes. They are willing to make
incompatible changes between minor point releases (but not patch
releases). Sometimes the changes are very subtle though and you may
not even notice them at compile time. This creates a problem for the
naive CMake written script where the user doesn't explicitly specify
which version they want. They might say they want Lua and are
implicitly assuming they want Lua 5.0 for example. But then on
somebody else's system, Lua 5.1 is picked up. It so happens the C-API
calls they used didn't change so the thing compiles, but when they
actually run the program, strange errors or crashing happens. This is
a very bad thing. So the best thing to do is force the CMake scripter
to explicitly choose which version of Lua they want to use. And in my
opinion, the most sure-fire way to make it obvious to the scripter
they have to choose is to make the module names different. And if they
want to opt-in and use either because they know they can use either,
the separate module system should allow them to do so and give them
the power to decide which version they want to prefer first.

There are also some historical factors. Lua 4 by default convention
tended to split the standard library into a separate dynamic library.
But not all packaging did this. For example, in an OS X style
framework, it is much more convenient to combine the libraries (like
in Lua 5). The Lua 4 script which I originally wrote and used for
internal use was extremely messy trying to handle this and other
quirks, and made the script unreadable when I got to Lua 5. I'm
anticipating that the future Lua's will continue to change things, so
I opted for separate scripts rather than one mess that I can't even
maintain.

-Eric


More information about the CMake mailing list