@@ -38,27 +38,30 @@ macro ( install_lua_executable _name _source )
38
38
# Find srlua and glue
39
39
find_program ( SRLUA_EXECUTABLE NAMES srlua )
40
40
find_program ( GLUE_EXECUTABLE NAMES glue )
41
-
41
+ # Executable output
42
+ set ( _exe ${CMAKE_CURRENT_BINARY_DIR} /${_name}${CMAKE_EXECUTABLE_SUFFIX} )
42
43
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
44
45
add_custom_command (
45
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR} / ${_name }
46
+ OUTPUT ${_exe }
46
47
COMMAND ${GLUE_EXECUTABLE}
47
- ARGS ${SRLUA_EXECUTABLE} ${_source} ${CMAKE_CURRENT_BINARY_DIR} / ${_name }
48
+ ARGS ${SRLUA_EXECUTABLE} ${_source} ${_exe }
48
49
DEPENDS ${_source}
49
50
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
50
51
VERBATIM
51
52
)
52
53
# Make sure we have a target associated with the binary
53
54
add_custom_target (${_name} ALL
54
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR} / ${_name }
55
+ DEPENDS ${_exe }
55
56
)
56
57
# 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 )
58
61
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
60
63
install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN}
61
- RENAME ${_source_name} .lua
64
+ RENAME ${_source_name}
62
65
COMPONENT Runtime
63
66
)
64
67
endif ()
0 commit comments