Fix development database user creation
[ryzomcore.git] / CMakeModules / FindLua54.cmake
blobb7daf269905428297eb41c8a6d1caf18dcad088d
1 # Locate Lua library
2 # This module defines
3 #  LUA54_FOUND, if false, do not try to link to Lua
4 #  LUA_LIBRARIES
5 #  LUA_INCLUDE_DIR, where to find lua.h
6 #  LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
8 # Note that the expected include convention is
9 #  #include "lua.h"
10 # and not
11 #  #include <lua/lua.h>
12 # This is because, the lua location is not standardized and may exist
13 # in locations other than lua/
15 #=============================================================================
16 # Copyright 2007-2009 Kitware, Inc.
18 # Distributed under the OSI-approved BSD License (the "License");
19 # see accompanying file Copyright.txt for details.
21 # This software is distributed WITHOUT ANY WARRANTY; without even the
22 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 # See the License for more information.
24 #=============================================================================
25 # (To distribute this file outside of CMake, substitute the full
26 #  License text for the above reference.)
28 find_path(LUA_INCLUDE_DIR lua.h
29   HINTS
30     ENV LUA_DIR
31   PATH_SUFFIXES include/lua54 include/lua5.4 include/lua-5.4 include/lua include
32   PATHS
33   ~/Library/Frameworks
34   /Library/Frameworks
35   /sw # Fink
36   /opt/local # DarwinPorts
37   /opt/csw # Blastwave
38   /opt
41 FIND_LIBRARY(LUA_LIBRARY
42   NAMES lua54 lua5.4 lua-5.4 lua
43   HINTS
44     $ENV{LUA_DIR}
45   PATH_SUFFIXES lib64 lib
46   PATHS
47   ~/Library/Frameworks
48   /Library/Frameworks
49   /sw
50   /opt/local
51   /opt/csw
52   /opt
55 FIND_LIBRARY(LUA_LIBRARY_DEBUG
56   NAMES lua54-d lua5.4-d lua-5.4-d lua-d lua54d lua5.4d lua-5.4d luad
57   HINTS
58     $ENV{LUA_DIR}
59   PATH_SUFFIXES lib64 lib
60   PATHS
61   ~/Library/Frameworks
62   /Library/Frameworks
63   /sw
64   /opt/local
65   /opt/csw
66   /opt
69 if(LUA_LIBRARY)
70   # include the math library for Unix
71   if(UNIX AND NOT APPLE AND NOT BEOS)
72     find_library(LUA_MATH_LIBRARY m)
73     set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
74   # For Windows and Mac, don't need to explicitly include the math library
75   else()
76     if (LUA_LIBRARY_DEBUG)
77       set( LUA_LIBRARIES optimized ${LUA_LIBRARY} debug ${LUA_LIBRARY_DEBUG} CACHE STRING "Lua Libraries")
78     else()
79       set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
80     endif()
81   endif()
82 endif()
84 if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
85   file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
87   string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
88   unset(lua_version_str)
89 endif()
91 include(FindPackageHandleStandardArgs)
92 # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
93 # all listed variables are TRUE
94 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua54
95                                   REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
96                                   VERSION_VAR LUA_VERSION_STRING)
98 mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_LIBRARY_DEBUG LUA_MATH_LIBRARY)