Browse Source

Link to Lua 5.3

Přemysl Janouch 1 year ago
parent
commit
101c58a136
Signed by: Přemysl Janouch <p.janouch@gmail.com> GPG Key ID: B715679E3A361BE6
2 changed files with 29 additions and 2 deletions
  1. 28
    2
      CMakeLists.txt
  2. 1
    0
      config.h.in

+ 28
- 2
CMakeLists.txt View File

@@ -48,6 +48,31 @@ else ()
48 48
 	set (Termo_LIBRARIES termo-static)
49 49
 endif ()
50 50
 
51
+set (project_libraries ${UNISTRING_LIBRARIES}
52
+	${NCURSESW_LIBRARIES} termo-static)
53
+
54
+pkg_search_module (lua lua53 lua5.3 lua-5.3 lua>=5.3)
55
+option (WITH_LUA "Enable support for Lua plugins" ${lua_FOUND})
56
+
57
+if (WITH_LUA)
58
+	if (NOT lua_FOUND)
59
+		message (FATAL_ERROR "Lua library not found")
60
+	endif ()
61
+
62
+	list (APPEND project_libraries ${lua_LIBRARIES})
63
+	include_directories (${lua_INCLUDE_DIRS})
64
+	link_directories (${lua_LIBRARY_DIRS})
65
+
66
+	include (CheckTypeSize)
67
+	set (CMAKE_REQUIRED_LIBRARIES ${lua_LIBRARIES})
68
+	set (CMAKE_REQUIRED_INCLUDES ${lua_INCLUDE_DIRS})
69
+	set (CMAKE_EXTRA_INCLUDE_FILES "lua.h")
70
+	CHECK_TYPE_SIZE (lua_Integer LUA_INTEGER)
71
+	if (NOT HAVE_LUA_INTEGER OR LUA_INTEGER LESS 8)
72
+		message (FATAL_ERROR "Lua must have at least 64-bit integers")
73
+	endif ()
74
+endif ()
75
+
51 76
 include_directories (${UNISTRING_INCLUDE_DIRS}
52 77
 	${NCURSESW_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS})
53 78
 
@@ -57,14 +82,15 @@ set (CMAKE_REQUIRED_LIBRARIES ${NCURSESW_LIBRARIES})
57 82
 CHECK_FUNCTION_EXISTS ("resizeterm" HAVE_RESIZETERM)
58 83
 
59 84
 # Generate a configuration file
85
+set (HAVE_LUA "${WITH_LUA}")
86
+
60 87
 configure_file (${PROJECT_SOURCE_DIR}/config.h.in
61 88
 	${PROJECT_BINARY_DIR}/config.h)
62 89
 include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
63 90
 
64 91
 # Build the main executable and link it
65 92
 add_executable (${PROJECT_NAME} ${PROJECT_NAME}.c)
66
-target_link_libraries (${PROJECT_NAME} ${UNISTRING_LIBRARIES}
67
-	${NCURSESW_LIBRARIES} termo-static)
93
+target_link_libraries (${PROJECT_NAME} ${project_libraries})
68 94
 add_threads (${PROJECT_NAME})
69 95
 
70 96
 # Installation

+ 1
- 0
config.h.in View File

@@ -5,6 +5,7 @@
5 5
 #define PROGRAM_VERSION "${project_VERSION}"
6 6
 
7 7
 #cmakedefine HAVE_RESIZETERM
8
+#cmakedefine HAVE_LUA
8 9
 
9 10
 #endif  // ! CONFIG_H
10 11
 

Loading…
Cancel
Save