File: lua.cmake

package info (click to toggle)
plplot 5.9.5-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 32,964 kB
  • ctags: 11,898
  • sloc: ansic: 71,866; xml: 25,294; cpp: 13,070; tcl: 10,310; f90: 5,963; perl: 5,661; python: 5,068; java: 4,944; ml: 4,057; sh: 1,754; php: 267; makefile: 198; lisp: 75; fortran: 64; sed: 5
file content (128 lines) | stat: -rw-r--r-- 4,777 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# cmake/modules/lua.cmake
#
# Lua binding configuration
#
# Copyright (C) 2008  Werner Smekal
#
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; version 2 of the License.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with the file PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# Module for determining Lua bindings configuration options

# Options to enable Lua bindings
if(DEFAULT_NO_BINDINGS)
  option(ENABLE_lua "Enable Lua bindings" OFF)
else(DEFAULT_NO_BINDINGS)
  option(ENABLE_lua "Enable Lua bindings" ON)
endif(DEFAULT_NO_BINDINGS)

if(ENABLE_lua AND NOT BUILD_SHARED_LIBS)
  message(STATUS "WARNING: "
    "Lua requires shared libraries. Disabling Lua bindings")
  set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
endif(ENABLE_lua AND NOT BUILD_SHARED_LIBS)

if(ENABLE_lua AND NOT SWIG_FOUND)
  message(STATUS "WARNING: "
    "swig not found. Disabling Lua bindings")
  set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
endif(ENABLE_lua AND NOT SWIG_FOUND)

if(ENABLE_lua)
  transform_version(NUMERICAL_SWIG_MINIMUM_VERSION_FOR_LUA "1.3.35")
  transform_version(NUMERICAL_SWIG_VERSION "${SWIG_VERSION}")
  if(NUMERICAL_SWIG_VERSION LESS "${NUMERICAL_SWIG_MINIMUM_VERSION_FOR_LUA}")
    message(STATUS "WARNING: swig version too old for Lua bindings.   Disabling Lua bindings.")
    set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
  endif(NUMERICAL_SWIG_VERSION LESS "${NUMERICAL_SWIG_MINIMUM_VERSION_FOR_LUA}")
endif(ENABLE_lua)

if(ENABLE_lua AND NOT PL_DOUBLE)
  message(STATUS "WARNING: "
    "only single precision floating point. Disabling Lua bindings")
  set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
endif(ENABLE_lua AND NOT PL_DOUBLE)

if(ENABLE_lua)
  # Check for Lua libraries which defines
  #  LUA_LIBRARIES    = path to the Lua library
  #  LUA_INCLUDE_DIR  = path to where lua.h is found
  option(HAVE_lua51 "Lua version is 5.1" OFF)
  if(HAVE_lua51)
    find_package(Lua51)
    # Variety of return values possible depending on whether 2.6.0 or later.
    if(DEFINED LUA50_FOUND)
      set(LUA_FOUND ${LUA50_FOUND})
    elseif(DEFINED LUA51_FOUND)
      set(LUA_FOUND ${LUA51_FOUND})
    endif(DEFINED LUA50_FOUND)
  else(HAVE_lua51)
    find_package(Lua50)
    set(LUA_FOUND LUA50_FOUND)
  endif(HAVE_lua51)
  if(NOT LUA_FOUND)
    message(STATUS "WARNING: "
      "Lua library and/or header not found. Disabling Lua bindings")
    set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
  endif(NOT LUA_FOUND)
endif(ENABLE_lua)

if(ENABLE_lua)
  find_program(LUA_EXECUTABLE lua)
  if(NOT LUA_EXECUTABLE)
    message(STATUS "WARNING: "
      "Lua executable not found. Disabling Lua bindings")
    set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
  endif(NOT LUA_EXECUTABLE)
endif(ENABLE_lua)

if(ENABLE_lua)
  # Check whether you have found a Lua executable that is consistent 
  # with the library version.
  execute_process(COMMAND ${LUA_EXECUTABLE} -v
    OUTPUT_VARIABLE LUA_VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE
    ERROR_VARIABLE LUA_VERSION
    ERROR_STRIP_TRAILING_WHITESPACE
    )
  #message("(preliminary) LUA_VERSION = ${LUA_VERSION}")
  string(REGEX MATCH "[0-9]\\.[0-9]\\.[0-9]" LUA_VERSION "${LUA_VERSION}")
  #message("(dotted triplet) LUA_VERSION = ${LUA_VERSION}")
  # Reduce to just major.minor for purposes of comparison.
  string(SUBSTRING "${LUA_VERSION}" 0 3 LUA_VERSION)
  message(STATUS "LUA_VERSION = ${LUA_VERSION}")
  set(LUA_VERSION_VALID)
  if(${LUA_VERSION} STREQUAL "5.0" AND NOT HAVE_lua51)
    set(LUA_VERSION_VALID ON)
  elseif(${LUA_VERSION} STREQUAL "5.1" AND HAVE_lua51)
    set(LUA_VERSION_VALID ON)
  endif(${LUA_VERSION} STREQUAL "5.0" AND NOT HAVE_lua51)

  if(NOT LUA_VERSION_VALID)
    message(STATUS "WARNING: "
      "Lua executable found but version not consistent with library. Disabling Lua bindings")
    set(ENABLE_lua OFF CACHE BOOL "Enable Lua bindings" FORCE)
  endif(NOT LUA_VERSION_VALID)
endif(ENABLE_lua)

if(ENABLE_lua)
  # Unless some better convention comes along, follow what Debian does for
  # install location of Lua wrapper shared object.
  if(HAVE_lua51)
    set(LUA_DIR ${LIB_DIR}/lua/5.1/plplot)
  else(HAVE_lua51)
    set(LUA_DIR ${LIB_DIR}/lua/50/plplot)
  endif(HAVE_lua51)
endif(ENABLE_lua)