1 # - Copy the resources your app needs to the build tree.
3 # copy_resources_to_build_tree(<target_name>)
5 # Requires CMake 2.6 or newer (uses the 'function' command)
8 # 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
9 # http://academic.cleardefinition.com
10 # Iowa State University HCI Graduate Program/VRAC
12 # Copyright Iowa State University 2009-2010.
13 # Distributed under the Boost Software License, Version 1.0.
14 # (See accompanying file LICENSE_1_0.txt or copy at
15 # http://www.boost.org/LICENSE_1_0.txt)
17 if(__copy_resources_to_build_tree)
20 set(__copy_resources_to_build_tree YES)
22 function(copy_resources_to_build_tree _target)
23 get_target_property(_resources ${_target} RESOURCE)
25 # Bail if no resources
27 "Told to copy resources for target ${_target}, but "
28 "no resources are set!")
32 get_target_property(_path ${_target} LOCATION)
33 get_filename_component(_path "${_path}" PATH)
35 if(NOT MSVC AND NOT "${CMAKE_GENERATOR}" MATCHES "Makefiles")
36 foreach(_config ${CMAKE_CONFIGURATION_TYPES})
37 get_target_property(_path${_config} ${_target} LOCATION_${_config})
38 get_filename_component(_path${_config} "${_path${_config}}" PATH)
39 add_custom_command(TARGET ${_target}
43 ARGS -E make_directory "${_path${_config}}/"
44 COMMENT "Creating directory ${_path${_config}}/")
48 foreach(_res ${_resources})
49 if(NOT IS_ABSOLUTE "${_res}")
50 get_filename_component(_res "${_res}" ABSOLUTE)
52 get_filename_component(_name "${_res}" NAME)
55 # Working dir is solution file dir, not exe file dir.
56 add_custom_command(TARGET ${_target}
60 ARGS -E copy "${_res}" "${CMAKE_BINARY_DIR}/"
61 COMMENT "Copying ${_name} to ${CMAKE_BINARY_DIR}/ for MSVC")
63 if("${CMAKE_GENERATOR}" MATCHES "Makefiles")
64 add_custom_command(TARGET ${_target}
68 ARGS -E copy "${_res}" "${_path}/"
69 COMMENT "Copying ${_name} to ${_path}/")
71 foreach(_config ${CMAKE_CONFIGURATION_TYPES})
72 add_custom_command(TARGET ${_target}
76 ARGS -E copy "${_res}" "${_path${_config}}"
77 COMMENT "Copying ${_name} to ${_path${_config}}")