-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# - Copy lua source files as a custom target | ||
# | ||
# include(LuaTargets) | ||
# add_lua_target(<target_name> <directory to copy to> [<luafile> <luafile>]) | ||
# Relative paths for the destination directory are considered with | ||
# with respect to CMAKE_CURRENT_BINARY_DIR | ||
# | ||
# install_lua_target(<target_name> [arguments to INSTALL(PROGRAMS ...) ]) | ||
# | ||
# | ||
# Requires CMake 2.6 or newer (uses the 'function' command) | ||
# | ||
# Original Author: | ||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> | ||
# http://academic.cleardefinition.com | ||
# Iowa State University HCI Graduate Program/VRAC | ||
|
||
if(__add_lua) | ||
return() | ||
endif() | ||
set(__add_lua YES) | ||
|
||
define_property(TARGET | ||
PROPERTY | ||
LUA_TARGET | ||
BRIEF_DOCS | ||
"Lua target" | ||
FULL_DOCS | ||
"Is this a Lua target created by add_lua_target?") | ||
|
||
function(add_lua_target _target _dest) | ||
if(NOT ARGN) | ||
message(WARNING "In add_lua_target call for target ${_target}, no Lua files were specified!") | ||
return() | ||
endif() | ||
|
||
set(ALLFILES) | ||
foreach(luafile ${ARGN}) | ||
add_custom_command(OUTPUT "${_dest}/${luafile}" | ||
COMMAND | ||
${CMAKE_COMMAND} | ||
ARGS -E make_directory "${_dest}" | ||
COMMAND | ||
${CMAKE_COMMAND} | ||
ARGS -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${luafile}" "${_dest}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${luafile}" | ||
COMMENT "Copying ${luafile} to ${_dest}/${luafile}") | ||
list(APPEND ALLFILES "${_dest}/${luafile}") | ||
endforeach() | ||
|
||
# Custom target depending on all the lua file commands | ||
add_custom_target(${_target} | ||
SOURCES ${ARGN} | ||
DEPENDS ${ALLFILES}) | ||
|
||
set_property(TARGET ${_target} PROPERTY LUA_TARGET YES) | ||
endfunction() | ||
|
||
function(install_lua_target _target) | ||
get_target_property(_isLua ${_target} LUA_TARGET) | ||
if(NOT _isLua) | ||
message(WARNING "install_lua_target called on a target not created with add_lua_target!") | ||
return() | ||
endif() | ||
|
||
# Get sources | ||
get_target_property(_srcs ${_target} SOURCES) | ||
|
||
# Remove the "fake" file forcing build | ||
list(REMOVE_AT _srcs 0) | ||
|
||
# Forward the call to install | ||
install(PROGRAMS ${_srcs} ${ARGN}) | ||
endfunction() |