Skip to content

Commit

Permalink
Update cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
rpavlik committed Jun 16, 2010
1 parent 94c6a2c commit d955003
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions FindGMTL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(GMTL_VERSIONS
0.5.4
0.6.0
0.6.1
0.6.2
${GMTL_ADDITIONAL_VERSIONS})
set(GMTL_DIRS)
foreach(_version ${GMTL_VERSIONS})
Expand Down
75 changes: 75 additions & 0 deletions LuaTargets.cmake
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()

0 comments on commit d955003

Please sign in to comment.