CMakeLists.txt
changeset 63 c17f3295f52c
parent 62 d92358eafead
child 65 72ffcf688664
--- a/CMakeLists.txt	Sat Mar 05 15:51:12 2016 +0200
+++ b/CMakeLists.txt	Sat Mar 05 17:32:12 2016 +0200
@@ -16,27 +16,44 @@
 
 cmake_minimum_required(VERSION 2.6)
 project(lua-lm C)
-set(PROJECT_VERSION "0.9.5")
+set(PROJECT_VERSION "0.9.6")
 
 ## User options
-option(DEBUG      "Enable debugging output" OFF)
-option(WANT_LUA52 "Force Lua 5.2 usage"     OFF)
+option(DEBUG         "Enable debugging output" OFF)
 set(TEST_USER        "test@jabber.org" CACHE STRING "Testing: Your jabber account name")
 set(TEST_PASSWORD    "greatsecret" CACHE STRING "Testing: Password for your jabber account")
 set(TEST_TO          "test@jabber.org/mcabber" CACHE STRING "Testing: Target jabber entity")
 set(TEST_FINGERPRINT "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff" CACHE STRING "Testing: Your jabber server SSL fingerprint")
+set(WANT_LUA         "AUTO" CACHE STRING "Lua version to use (You'll have to define this with -DWANT_LUA=LUAX.X)")
+set_property(CACHE WANT_LUA PROPERTY STRINGS "AUTO" "LUA5.1" "LUA5.2" "LUA5.3")
 
 ## Gather information about system
 find_package(PkgConfig REQUIRED)
-if(NOT WANT_LUA52)
-	find_package(Lua51)
-endif()
-if(WANT_LUA52 OR NOT LUA51_FOUND)
+if(WANT_LUA STREQUAL "LUA5.3")
+	pkg_check_modules(LUA REQUIRED lua5.3)
+	set(LUA_VERSION "5.3")
+elseif(WANT_LUA STREQUAL "LUA5.2")
 	pkg_check_modules(LUA REQUIRED lua5.2)
 	set(LUA_VERSION "5.2")
-	set(HAVE_LUA52 "1")
+elseif(WANT_LUA STREQUAL "LUA5.1")
+	find_package(Lua51 REQUIRED)
+	set(LUA_VERSION "5.1")
 else()
-	set(LUA_VERSION "5.1")
+	pkg_check_modules(LUA lua5.3)
+	if(LUA_FOUND)
+		set(LUA_VERSION "5.3")
+	else()
+		pkg_check_modules(LUA lua5.2)
+		if(LUA_FOUND)
+			set(LUA_VERSION "5.2")
+		else()
+			find_package(Lua51 REQUIRED)
+			set(LUA_VERSION "5.1")
+		endif()
+	endif()
+endif()
+if(LUA_VERSION STREQUAL "5.1")
+	set(LUA51_COMPATIBILITY TRUE)
 	set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
 endif()
 find_program(LUA_EXECUTABLE lua${LUA_VERSION} lua luanoreadline)