PROJECT(luajit-rocks)

# We want release compilation by default
IF(NOT CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE Release CACHE STRING
      "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)

CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.6)

OPTION(WITH_LUA51 "Use Lua 5.1 instead of LuaJIT 2.1" OFF)
OPTION(WITH_LUA52 "Use Lua 5.2 instead of LuaJIT 2.1" OFF)
OPTION(WITH_LUA53 "Use Lua 5.3 instead of LuaJIT 2.1" OFF)
OPTION(WITH_LUAJIT21 "Use LuaJIT 2.1 instead of LuaJIT 2.0" OFF)
OPTION(WITH_SYSTEM_LUAJIT "Use LuaJIT installed on the system" OFF)
OPTION(WITH_LUAROCKS "Install Luarocks" ON)

IF(WITH_LUA51)
  SET(LUA_EXE_NAME lua)
  SET(LUA_VERSION 5.1)
  ADD_SUBDIRECTORY(lua-5.1)
ELSEIF(WITH_LUA51RC)
  SET(LUA_EXE_NAME lua)
  SET(LUA_VERSION 5.1)
  ADD_SUBDIRECTORY(lua-5.1-rc)
ELSEIF(WITH_LUA52)
  SET(LUA_EXE_NAME lua)
  SET(LUA_VERSION 5.2)
  ADD_SUBDIRECTORY(lua-5.2)
ELSEIF(WITH_LUA53)
  SET(LUA_EXE_NAME lua)
  SET(LUA_VERSION 5.3)
  ADD_SUBDIRECTORY(lua-5.3)
ELSEIF(WITH_LUAJIT21)
  SET(LUA_EXE_NAME luajit)
  SET(LUA_VERSION 5.1)
  ADD_SUBDIRECTORY(luajit-2.1)
ELSEIF(WITH_SYSTEM_LUAJIT)
  SET(LUA_EXE_NAME luajit)
  SET(LUA_VERSION 5.1)
ELSE()
  SET(LUA_EXE_NAME luajit)
  SET(LUA_VERSION 5.1)
  ADD_SUBDIRECTORY(luajit-2.0)
ENDIF()

IF(WITH_LUAROCKS)
  ADD_SUBDIRECTORY(luarocks)
ENDIF(WITH_LUAROCKS)
