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

Commit f96ee8d

Browse files
committed
Updated lua macro
1 parent bcd15c5 commit f96ee8d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

cmake/lua.cmake

+11-8
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,30 @@ macro ( install_lua_executable _name _source )
3838
# Find srlua and glue
3939
find_program( SRLUA_EXECUTABLE NAMES srlua )
4040
find_program( GLUE_EXECUTABLE NAMES glue )
41-
41+
# Executable output
42+
set ( _exe ${CMAKE_CURRENT_BINARY_DIR}/${_name}${CMAKE_EXECUTABLE_SUFFIX} )
4243
if ( NOT SKIP_LUA_WRAPPER AND SRLUA_EXECUTABLE AND GLUE_EXECUTABLE )
43-
# Generate binary gluing the lua code to srlua
44+
# Generate binary gluing the lua code to srlua, this is a robuust approach for most systems
4445
add_custom_command(
45-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
46+
OUTPUT ${_exe}
4647
COMMAND ${GLUE_EXECUTABLE}
47-
ARGS ${SRLUA_EXECUTABLE} ${_source} ${CMAKE_CURRENT_BINARY_DIR}/${_name}
48+
ARGS ${SRLUA_EXECUTABLE} ${_source} ${_exe}
4849
DEPENDS ${_source}
4950
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
5051
VERBATIM
5152
)
5253
# Make sure we have a target associated with the binary
5354
add_custom_target(${_name} ALL
54-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_name}
55+
DEPENDS ${_exe}
5556
)
5657
# Install with run permissions
57-
install ( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${_name} DESTINATION ${INSTALL_BIN} COMPONENT Runtime)
58+
install ( PROGRAMS ${_exe} DESTINATION ${INSTALL_BIN} COMPONENT Runtime)
59+
# Also install source as optional resurce
60+
install ( FILES ${_source} DESTINATION ${INSTALL_FOO} COMPONENT Other )
5861
else()
59-
# Add .lua suffix and install as is
62+
# Install into bin as is but without the lua suffix, we assume the executable uses UNIX shebang/hash-bang magic
6063
install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN}
61-
RENAME ${_source_name}.lua
64+
RENAME ${_source_name}
6265
COMPONENT Runtime
6366
)
6467
endif()

0 commit comments

Comments
 (0)