Skip to content

Commit 0e8b140

Browse files
committed
Updated cmake macros
1 parent eea03d7 commit 0e8b140

File tree

6 files changed

+813
-549
lines changed

6 files changed

+813
-549
lines changed

.travis.yml

+23-22
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,40 @@
22
# LuaDist Travis-CI Hook
33
#
44

5-
# Since CMake is not directly supported we use erlang VMs
6-
language: erlang
7-
5+
# We assume C build environments
6+
language: C
7+
88
# Try using multiple Lua Implementations
99
env:
10-
- LUA="" # Use automatic dependencies
11-
- LUA="luajit" # Try with LuaJIT
12-
# - CMAKE="-DCMAKE_VARIABLE=value"
13-
# - LUA="lua-5.1.5"
10+
- TOOL="" # Use native compiler (GCC usually)
11+
- COMPILER="clang" # Use clang
12+
- TOOL="i686-w64-mingw32" # 32bit MinGW
13+
- TOOL="x86_64-w64-mingw32" # 64bit MinGW
14+
- TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux
1415

15-
# Allow luajit to fail
16+
# Crosscompile builds may fail
1617
matrix:
1718
allow_failures:
18-
- env: LUA="luajit"
19-
20-
# We need CMake and LuaDist
19+
- env: TOOL="i686-w64-mingw32"
20+
- env: TOOL="x86_64-w64-mingw32"
21+
- env: TOOL="arm-linux-gnueabihf"
22+
23+
# Install dependencies
2124
install:
22-
- export MODULE=`basename $PWD`
23-
- sudo apt-get install cmake >/dev/null 2>&1
24-
- git clone git://github.com/LuaDist/bootstrap.git _luadist >/dev/null 2>&1
25-
- cd _luadist
26-
- git submodule update --init >/dev/null 2>&1
27-
- ./bootstrap >/dev/null 2>&1
28-
- export LUADIST=$PWD/_install/bin/luadist
29-
- cd $HOME
25+
- git clone git://github.com/LuaDist/_util.git ~/_util
26+
- ~/_util/travis install
27+
28+
# Bootstap
29+
before_script:
30+
- ~/_util/travis bootstrap
3031

31-
# Use LuaDist to deploy the module
32+
# Build the module
3233
script:
33-
- $LUADIST _test install $LUA $MODULE-scm $CMAKE -verbose=true -test=true
34+
- ~/_util/travis build
3435

3536
# Execute additional tests or commands
3637
#after_script:
37-
# - [run additional test commans]
38+
# - ~/_util/travis test
3839

3940
# Only watch the master branch
4041
branches:

CMakeLists.txt

+58-77
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,78 @@
1-
# Copyright (C) 2007-2009 LuaDist.
2-
# Created by Peter Kapec, David Manura
1+
# Copyright (C) 2007-2012 LuaDist.
2+
# Created by Peter Kapec, David Manura, Peter Drahoš
33
# Redistribution and use of this file is allowed according to the terms of the MIT license.
44
# For details see the COPYRIGHT file distributed with LuaDist.
55
# Please note that the package source code is licensed under its own license.
66

7-
project(luacom C CXX)
8-
cmake_minimum_required(VERSION 2.6)
9-
include(dist.cmake)
10-
include(CheckCSourceCompiles)
11-
include(CheckSymbolExists) # note: requires 'C' in PROJECT.
7+
project ( luacom C CXX )
8+
cmake_minimum_required ( VERSION 2.8 )
9+
include ( cmake/dist.cmake )
10+
include ( lua )
11+
include ( CheckCSourceCompiles )
12+
include ( CheckSymbolExists )
13+
# note: requires 'C' in PROJECT.
1214

1315
# Build
14-
include_directories(include src/dll src/library ${CMAKE_CURRENT_BINARY_DIR})
16+
include_directories ( include src/dll src/library ${CMAKE_CURRENT_BINARY_DIR} )
1517

1618
# Detect htmlhelp (not normally available in Cygwin 1.7, MinGW, and Wine).
1719
# Use CHECK_C_SOURCE_COMPILES because these two aren't reliable:
1820
# CHECK_INCLUDE_FILES("windows.h;htmlhelp.h" HAVE_HTMLHELP)
1921
# # On MinGW and Wine, htmlhelp.h may exist but not htmlhelp.lib.
2022
# CHECK_LIBRARY_EXISTS(htmlhelp HtmlHelpA "" HAVE_HTMLHELP) # detection fails in MSVC
21-
set(CMAKE_REQUIRED_LIBRARIES htmlhelp)
22-
check_c_source_compiles("
23-
#include <windows.h>
24-
#include <htmlhelp.h>
25-
int main() { HtmlHelp(NULL, NULL, HH_HELP_CONTEXT, 0); return 0; }
26-
" HAVE_HTMLHELP)
27-
set(CMAKE_REQUIRED_LIBRARIES)
28-
if(NOT HAVE_HTMLHELP)
29-
add_definitions(-DNO_HTMLHELP)
30-
endif()
23+
set ( CMAKE_REQUIRED_LIBRARIES htmlhelp )
24+
check_c_source_compiles ( " #include <windows.h> #include <htmlhelp.h> int main() { HtmlHelp(NULL, NULL, HH_HELP_CONTEXT, 0); return 0; } "
25+
HAVE_HTMLHELP )
26+
set ( CMAKE_REQUIRED_LIBRARIES )
27+
if ( NOT HAVE_HTMLHELP )
28+
add_definitions ( -DNO_HTMLHELP )
29+
endif ( )
3130

3231
# _stricmp (is there a simpler way of doing this?)
33-
check_symbol_exists(_stricmp string.h HAVE__STRICMP)
34-
if(HAVE__STRICMP)
35-
set(STRICMP _stricmp)
36-
endif()
37-
if(NOT STRICMP)
38-
check_symbol_exists(stricmp string.h HAVE_STRICMP)
39-
if(HAVE_STRICMP)
40-
set(STRICMP stricmp)
41-
endif()
42-
endif()
43-
if(NOT STRICMP)
44-
check_symbol_exists(strcasecmp string.h HAVE_STRCASECMP)
45-
if(HAVE_STRCASECMP)
46-
set(STRICMP strcasecmp)
47-
endif()
48-
endif()
49-
if(NOT STRICMP)
50-
message(FATAL_ERROR "_stricmp, stricmp, or strcasecmp not found")
51-
endif()
52-
add_definitions(-D_stricmp=${STRICMP})
32+
check_symbol_exists ( _stricmp string.h HAVE__STRICMP )
33+
if ( HAVE__STRICMP )
34+
set ( STRICMP _stricmp )
35+
endif ( )
36+
if ( NOT STRICMP )
37+
check_symbol_exists ( stricmp string.h HAVE_STRICMP )
38+
if ( HAVE_STRICMP )
39+
set ( STRICMP stricmp )
40+
endif ( )
41+
endif ( )
42+
if ( NOT STRICMP )
43+
check_symbol_exists ( strcasecmp string.h HAVE_STRCASECMP )
44+
if ( HAVE_STRCASECMP )
45+
set ( STRICMP strcasecmp )
46+
endif ( )
47+
endif ( )
48+
if ( NOT STRICMP )
49+
message ( FATAL_ERROR "_stricmp, stricmp, or strcasecmp not found" )
50+
endif ( )
51+
add_definitions ( -D_stricmp=${STRICMP} )
5352

54-
set(SRC_LIB
55-
src/library/LuaAux.cpp
56-
src/library/luabeans.cpp
57-
src/library/luacom.cpp
58-
src/library/tLuaCOM.cpp
59-
src/library/tLuaCOMException.cpp
60-
src/library/tLuaCOMTypeHandler.cpp
61-
src/library/tLuaDispatch.cpp
62-
src/library/tLuaObjList.cpp
63-
src/library/tLuaVector.cpp
64-
src/library/tStringBuffer.cpp
65-
src/library/tUtil.cpp
66-
src/library/tCOMUtil.cpp
67-
src/library/tLuaCOMClassFactory.cpp
68-
src/library/tLuaCOMConnPoints.cpp
69-
src/library/LuaCompat.cpp
70-
src/library/tLuaCOMEnumerator.cpp
71-
src/library/tLuaObject.cpp
72-
src/library/tLuaControl.cpp
73-
src/library/tLuaTLB.cpp
74-
)
53+
set ( SRC_LIB src/library/LuaAux.cpp src/library/luabeans.cpp src/library/luacom.cpp
54+
src/library/tLuaCOM.cpp src/library/tLuaCOMException.cpp src/library/tLuaCOMTypeHandler.cpp
55+
src/library/tLuaDispatch.cpp src/library/tLuaObjList.cpp src/library/tLuaVector.cpp
56+
src/library/tStringBuffer.cpp src/library/tUtil.cpp src/library/tCOMUtil.cpp src/library/tLuaCOMClassFactory.cpp
57+
src/library/tLuaCOMConnPoints.cpp src/library/LuaCompat.cpp src/library/tLuaCOMEnumerator.cpp
58+
src/library/tLuaObject.cpp src/library/tLuaControl.cpp src/library/tLuaTLB.cpp )
7559

76-
set(LIBS gdi32 shell32 advapi32 ole32 winspool uuid oleaut32 shlwapi) # kernel32 user32
77-
if(HAVE_HTMLHELP)
78-
set(LIBS ${LIBS} htmlhelp)
79-
endif()
60+
set ( LIBS gdi32 shell32 advapi32 ole32 winspool uuid oleaut32 shlwapi )
61+
# kernel32 user32
62+
if ( HAVE_HTMLHELP )
63+
set ( LIBS ${LIBS} htmlhelp )
64+
endif ( )
8065

81-
add_lua_bin2c(
82-
${CMAKE_CURRENT_BINARY_DIR}/luacom5.loh src/library/luacom5.lua
83-
${CMAKE_CURRENT_SOURCE_DIR}/mak/bin2c.lua
84-
${CMAKE_CURRENT_SOURCE_DIR}/mak/luac.lua)
85-
set_source_files_properties(src/library/luacom.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/luacom5.loh)
66+
add_lua_bin2c ( ${CMAKE_CURRENT_BINARY_DIR}/luacom5.loh src/library/luacom5.lua ${CMAKE_CURRENT_SOURCE_DIR}/mak/bin2c.lua
67+
${CMAKE_CURRENT_SOURCE_DIR}/mak/luac.lua )
68+
set_source_files_properties ( src/library/luacom.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/luacom5.loh )
8669

87-
set(SRC_DLL src/dll/luacom_dll.cpp)
88-
add_definitions(-DLUACOM_DLL="luacom.dll")
70+
set ( SRC_DLL src/dll/luacom_dll.cpp )
71+
add_definitions ( -DLUACOM_DLL="luacom.dll" )
8972

90-
install_lua_module(luacom ${SRC_DLL} ${SRC_LIB} src/dll/luacom_dll.def)
91-
target_link_libraries(luacom ${LIBS})
73+
install_lua_module ( luacom ${SRC_DLL} ${SRC_LIB} src/dll/luacom_dll.def LINK ${LIBS} )
74+
install_data ( README COPYRIGHT announce.txt todo.txt )
75+
install_doc ( doc/luacom.gif doc/luacom.pdf www/index.html )
76+
install_example ( demo/ )
9277

93-
install_data(README COPYRIGHT announce.txt todo.txt)
94-
install_doc(doc/luacom.gif doc/luacom.pdf www/index.html)
95-
install_example(demo/)
96-
97-
add_lua_test(${CMAKE_CURRENT_SOURCE_DIR}/src/test/luacom_tests5.lua)
78+
add_lua_test ( ${CMAKE_CURRENT_SOURCE_DIR}/src/test/luacom_tests5.lua )

cmake/FindLua.cmake

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Locate Lua library
2+
# This module defines
3+
# LUA_EXECUTABLE, if found
4+
# LUA_FOUND, if false, do not try to link to Lua
5+
# LUA_LIBRARIES
6+
# LUA_INCLUDE_DIR, where to find lua.h
7+
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
8+
#
9+
# Note that the expected include convention is
10+
# #include "lua.h"
11+
# and not
12+
# #include <lua/lua.h>
13+
# This is because, the lua location is not standardized and may exist
14+
# in locations other than lua/
15+
16+
#=============================================================================
17+
# Copyright 2007-2009 Kitware, Inc.
18+
# Modified to support Lua 5.2 by LuaDist 2012
19+
#
20+
# Distributed under the OSI-approved BSD License (the "License");
21+
# see accompanying file Copyright.txt for details.
22+
#
23+
# This software is distributed WITHOUT ANY WARRANTY; without even the
24+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25+
# See the License for more information.
26+
#=============================================================================
27+
# (To distribute this file outside of CMake, substitute the full
28+
# License text for the above reference.)
29+
#
30+
# The required version of Lua can be specified using the
31+
# standard syntax, e.g. FIND_PACKAGE(Lua 5.1)
32+
# Otherwise the module will search for any available Lua implementation
33+
34+
# Always search for non-versioned lua first (recommended)
35+
SET(_POSSIBLE_LUA_INCLUDE include include/lua)
36+
SET(_POSSIBLE_LUA_EXECUTABLE lua)
37+
SET(_POSSIBLE_LUA_LIBRARY lua)
38+
39+
# Determine possible naming suffixes (there is no standard for this)
40+
IF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
41+
SET(_POSSIBLE_SUFFIXES "${Lua_FIND_VERSION_MAJOR}${Lua_FIND_VERSION_MINOR}" "${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}" "-${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}")
42+
ELSE(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
43+
SET(_POSSIBLE_SUFFIXES "52" "5.2" "-5.2" "51" "5.1" "-5.1")
44+
ENDIF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
45+
46+
# Set up possible search names and locations
47+
FOREACH(_SUFFIX ${_POSSIBLE_SUFFIXES})
48+
LIST(APPEND _POSSIBLE_LUA_INCLUDE "include/lua${_SUFFIX}")
49+
LIST(APPEND _POSSIBLE_LUA_EXECUTABLE "lua${_SUFFIX}")
50+
LIST(APPEND _POSSIBLE_LUA_LIBRARY "lua${_SUFFIX}")
51+
ENDFOREACH(_SUFFIX)
52+
53+
# Find the lua executable
54+
FIND_PROGRAM(LUA_EXECUTABLE
55+
NAMES ${_POSSIBLE_LUA_EXECUTABLE}
56+
)
57+
58+
# Find the lua header
59+
FIND_PATH(LUA_INCLUDE_DIR lua.h
60+
HINTS
61+
$ENV{LUA_DIR}
62+
PATH_SUFFIXES ${_POSSIBLE_LUA_INCLUDE}
63+
PATHS
64+
~/Library/Frameworks
65+
/Library/Frameworks
66+
/usr/local
67+
/usr
68+
/sw # Fink
69+
/opt/local # DarwinPorts
70+
/opt/csw # Blastwave
71+
/opt
72+
)
73+
74+
# Find the lua library
75+
FIND_LIBRARY(LUA_LIBRARY
76+
NAMES ${_POSSIBLE_LUA_LIBRARY}
77+
HINTS
78+
$ENV{LUA_DIR}
79+
PATH_SUFFIXES lib64 lib
80+
PATHS
81+
~/Library/Frameworks
82+
/Library/Frameworks
83+
/usr/local
84+
/usr
85+
/sw
86+
/opt/local
87+
/opt/csw
88+
/opt
89+
)
90+
91+
IF(LUA_LIBRARY)
92+
# include the math library for Unix
93+
IF(UNIX AND NOT APPLE)
94+
FIND_LIBRARY(LUA_MATH_LIBRARY m)
95+
SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
96+
# For Windows and Mac, don't need to explicitly include the math library
97+
ELSE(UNIX AND NOT APPLE)
98+
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
99+
ENDIF(UNIX AND NOT APPLE)
100+
ENDIF(LUA_LIBRARY)
101+
102+
# Determine Lua version
103+
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
104+
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
105+
106+
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
107+
UNSET(lua_version_str)
108+
ENDIF()
109+
110+
INCLUDE(FindPackageHandleStandardArgs)
111+
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
112+
# all listed variables are TRUE
113+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
114+
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
115+
VERSION_VAR LUA_VERSION_STRING)
116+
117+
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE)
118+

0 commit comments

Comments
 (0)