summaryrefslogtreecommitdiff
path: root/LuaInstallDirs.cmake
blob: 86dec3227c1d8d74dbcc32f5f7404e4ce097ef3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#[=======================================================================[.rst:
LuaInstallDirs
--------------

Define Lua modules installation directories based on GNU standard installation
directories.

Result variables
^^^^^^^^^^^^^^^^

Similarly to GNUInstallDirs this modules defines ``CMAKE_INSTALL_<dir>`` and ``CMAKE_INSTALL_FULL_<dir>``. Refer to
GNUInstallDirs for detailed explanation. Here, ``<dir>`` is one of:

``LUA_CMOD``
  C-modules for use in Lua
``LUA_LMOD``
  Pure Lua modules
#]=======================================================================]
cmake_policy(PUSH)
cmake_policy(VERSION 3.20)  # 3rd argument in GNUInstallDirs_get_absolute_install_dir
set(LUA_VERSION "5.4" CACHE STRING "Lua version in major.minor format")  # MAYBE: Cooperate with FindLua
include(GNUInstallDirs)  # MAYBE: Consider GNUInstallDirs as optional
set(
	CMAKE_INSTALL_LUA_CMOD "${CMAKE_INSTALL_LIBDIR}/lua/${LUA_VERSION}" CACHE FILEPATH
	"Path to install Lua C-modules to") 
set(
	CMAKE_INSTALL_LUA_LMOD "${CMAKE_INSTALL_DATADIR}/lua/${LUA_VERSION}" CACHE FILEPATH
	"Path to install pure Lua modules to") 
mark_as_advanced(
	CMAKE_INSTALL_LUA_CMOD
	CMAKE_INSTALL_LUA_LMOD)
GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_LUA_CMOD CMAKE_INSTALL_LUA_CMOD LIBDIR)
GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_LUA_LMOD CMAKE_INSTALL_LUA_LMOD DATADIR)
cmake_policy(POP)