aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/Modules/FindLuaJIT.cmake
blob: 432aabb1212c175d291547f8318acd8a34153218 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# - Try to find LuaJIT
# Once done this will define
#
#  LUAJIT_FOUND - system has LuaJIT
#  LUAJIT_INCLUDE_DIR - the LuaJIT include directory
#  LUAJIT_LIBRARIES - Link these to use LuaJIT
#  LUAJIT_DEFINITIONS - Compiler switches required for using LuaJIT
#
#=============================================================================
#  Copyright (c) 2016 Andrea Schneider <asn@cryptomilk.org>
#
#  Distributed under the OSI-approved BSD License (the "License");
#  see accompanying file Copyright.txt for details.
#
#  This software is distributed WITHOUT ANY WARRANTY; without even the
#  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#  See the License for more information.
#=============================================================================
#

if (UNIX)
  find_package(PkgConfig)
  if (PKG_CONFIG_FOUND)
    pkg_check_modules(_LUAJIT luajit)
  endif (PKG_CONFIG_FOUND)
endif (UNIX)

set(_LUAJIT_ROOT_HINTS
    ${RSPAMD_SEARCH_PATH}
    ${LUAJIT_ROOT_DIR}
    ENV LUAJIT_ROOT_DIR
)

find_path(LUAJIT_INCLUDE_DIR
    NAMES
        luajit.h
    PATHS
        ${_LUAJIT_INCLUDEDIR}
    HINTS
        ${_LUAJIT_ROOT_HINTS}
    PATH_SUFFIXES
        luajit-5_1-2.0
        luajit-5_2-2.0
        luajit-5_3-2.0
)

find_library(LUAJIT_LIBRARY
    NAMES
        luajit
        luajit-5.1
        luajit-5.2
        luajit-5.3
    HINTS
        ${_LUAJIT_ROOT_HINTS}
    PATHS
        ${_LUAJIT_LIBDIR}
)

if (LUAJIT_LIBRARY)
    set(LUAJIT_LIBRARIES
        ${LUAJIT_LIBRARIES}
        ${LUAJIT_LIBRARY}
    )
endif (LUAJIT_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LuaJIT DEFAULT_MSG LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR)

# show the LUAJIT_INCLUDE_DIR and LUAJIT_LIBRARIES variables only in the advanced view
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES)