Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Updated cmake macros
Browse files Browse the repository at this point in the history
  • Loading branch information
drahosp committed Aug 25, 2012
1 parent a9aba11 commit d94210d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 40 deletions.
51 changes: 51 additions & 0 deletions .travis.yml
@@ -0,0 +1,51 @@
#
# LuaDist Travis-CI Hook
#

# We assume C build environments
language: C

# Try using multiple Lua Implementations
env:
- TOOL="" # Use native compiler (GCC usually)
- COMPILER="clang" # Use clang
- TOOL="i686-w64-mingw32" # 32bit MinGW
- TOOL="x86_64-w64-mingw32" # 64bit MinGW
- TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux

# Crosscompile builds may fail
matrix:
allow_failures:
- env: TOOL="i686-w64-mingw32"
- env: TOOL="x86_64-w64-mingw32"
- env: TOOL="arm-linux-gnueabihf"

# Install dependencies
install:
- git clone git://github.com/LuaDist/_util.git ~/_util
- ~/_util/travis install

# Bootstap
before_script:
- ~/_util/travis bootstrap

# Build the module
script:
- ~/_util/travis build

# Execute additional tests or commands
#after_script:
# - ~/_util/travis test

# Only watch the master branch
branches:
only:
- master

# Notify the LuaDist Dev group if needed
notifications:
recipients:
- luadist-dev@googlegroups.com
email:
on_success: change
on_failure: always
55 changes: 23 additions & 32 deletions CMakeLists.txt
Expand Up @@ -11,43 +11,34 @@ include ( lua )

# Optionally rebuild buildvm_*.h header.
option ( LUAFFI_RUN_DYNASM "Re-generate headers with DynASM." OFF )
if (LUAFFI_RUN_DYNASM)
if ( LUAFFI_RUN_DYNASM )
# We need LUA_EXECUTABLE
find_package ( Lua REQUIRED )

set(DASM ${LUA} ${CMAKE_CURRENT_SOURCE_DIR}/dynasm/dynasm.lua)
set(DASM_FLAGS_X86)
set(DASM_FLAGS_X64 -D X64)
set(DASM_FLAGS_X64WIN -D X64 -D X64WIN)

add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.h
COMMAND ${LUA_EXECUTABLE} ${DASM} -LN ${DASM_FLAGS_X86} -o ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.h ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/call_x64.h
COMMAND ${LUA_EXECUTABLE} ${DASM} -LN ${DASM_FLAGS_X64} -o ${CMAKE_CURRENT_SOURCE_DIR}/call_x64.h ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/call_x64win.h
COMMAND ${LUA_EXECUTABLE} ${DASM} -LN ${DASM_FLAGS_X64WIN} -o ${CMAKE_CURRENT_SOURCE_DIR}/call_x64win.h ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
)

find_package ( Lua REQUIRED )

set ( DASM ${LUA} ${CMAKE_CURRENT_SOURCE_DIR}/dynasm/dynasm.lua )
set ( DASM_FLAGS_X86 )
set ( DASM_FLAGS_X64 -D X64 )
set ( DASM_FLAGS_X64WIN -D X64 -D X64WIN )

add_custom_command ( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.h COMMAND ${LUA_EXECUTABLE}
${DASM} -LN ${DASM_FLAGS_X86} -o ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.h ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc )
add_custom_command ( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/call_x64.h COMMAND ${LUA_EXECUTABLE}
${DASM} -LN ${DASM_FLAGS_X64} -o ${CMAKE_CURRENT_SOURCE_DIR}/call_x64.h ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc )
add_custom_command ( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/call_x64win.h COMMAND ${LUA_EXECUTABLE}
${DASM} -LN ${DASM_FLAGS_X64WIN} -o ${CMAKE_CURRENT_SOURCE_DIR}/call_x64win.h
${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/call_x86.dasc )
# Note: not all of these are needed for the current platform, but for simplicity
# specify all.
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/call.c PROPERTIES OBJECT_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/call_x64win.h
${CMAKE_CURRENT_SOURCE_DIR}/call_x64.h
${CMAKE_CURRENT_SOURCE_DIR}/call_x86.h
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif ()
set_source_files_properties ( ${CMAKE_CURRENT_SOURCE_DIR}/call.c PROPERTIES OBJECT_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/call_x64win.h ${CMAKE_CURRENT_SOURCE_DIR}/call_x64.h
${CMAKE_CURRENT_SOURCE_DIR}/call_x86.h )
include_directories ( ${CMAKE_CURRENT_BINARY_DIR} )
endif ( )

install_lua_module ( ffi ffi.c ctype.c parser.c call.c )

install_data ( README.md )

add_library ( test_cdecl MODULE test.c )
install (TARGETS test_cdecl DESTINATION ${INSTALL_TEST} COMPONENT Test )
install ( TARGETS test_cdecl DESTINATION ${INSTALL_TEST} COMPONENT Test )
install_test ( test.lua )

19 changes: 11 additions & 8 deletions cmake/lua.cmake
Expand Up @@ -38,27 +38,30 @@ macro ( install_lua_executable _name _source )
# Find srlua and glue
find_program( SRLUA_EXECUTABLE NAMES srlua )
find_program( GLUE_EXECUTABLE NAMES glue )

# Executable output
set ( _exe ${CMAKE_CURRENT_BINARY_DIR}/${_name}${CMAKE_EXECUTABLE_SUFFIX} )
if ( NOT SKIP_LUA_WRAPPER AND SRLUA_EXECUTABLE AND GLUE_EXECUTABLE )
# Generate binary gluing the lua code to srlua
# Generate binary gluing the lua code to srlua, this is a robuust approach for most systems
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
OUTPUT ${_exe}
COMMAND ${GLUE_EXECUTABLE}
ARGS ${SRLUA_EXECUTABLE} ${_source} ${CMAKE_CURRENT_BINARY_DIR}/${_name}
ARGS ${SRLUA_EXECUTABLE} ${_source} ${_exe}
DEPENDS ${_source}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
# Make sure we have a target associated with the binary
add_custom_target(${_name} ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_name}
DEPENDS ${_exe}
)
# Install with run permissions
install ( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${_name} DESTINATION ${INSTALL_BIN} COMPONENT Runtime)
install ( PROGRAMS ${_exe} DESTINATION ${INSTALL_BIN} COMPONENT Runtime)
# Also install source as optional resurce
install ( FILES ${_source} DESTINATION ${INSTALL_FOO} COMPONENT Other )
else()
# Add .lua suffix and install as is
# Install into bin as is but without the lua suffix, we assume the executable uses UNIX shebang/hash-bang magic
install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN}
RENAME ${_source_name}.lua
RENAME ${_source_name}
COMPONENT Runtime
)
endif()
Expand Down

0 comments on commit d94210d

Please sign in to comment.