You did not post the full output of cmake. If you have both lua's installed its possible that cmake is using one of the versions but the code is not knowing which one and thus the special macro's for that version are not triggered.
set LUA_INCLUDE_DIR AND LUA_LIBRARIES to the lua 5.1 paths when running cmake.