From 0915b3ef56dfac3113cce55a59a5765dc94976be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:34:54 +0200 Subject: Adding upstream version 2.13.6. Signed-off-by: Daniel Baumann --- third-party/cmake/CopyResourcesToBuildTree.cmake | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 third-party/cmake/CopyResourcesToBuildTree.cmake (limited to 'third-party/cmake/CopyResourcesToBuildTree.cmake') diff --git a/third-party/cmake/CopyResourcesToBuildTree.cmake b/third-party/cmake/CopyResourcesToBuildTree.cmake new file mode 100644 index 0000000..3512cc4 --- /dev/null +++ b/third-party/cmake/CopyResourcesToBuildTree.cmake @@ -0,0 +1,83 @@ +# - Copy the resources your app needs to the build tree. +# +# copy_resources_to_build_tree() +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__copy_resources_to_build_tree) + return() +endif() +set(__copy_resources_to_build_tree YES) + +function(copy_resources_to_build_tree _target) + get_target_property(_resources ${_target} RESOURCE) + if(NOT _resources) + # Bail if no resources + message(STATUS + "Told to copy resources for target ${_target}, but " + "no resources are set!") + return() + endif() + + get_target_property(_path ${_target} LOCATION) + get_filename_component(_path "${_path}" PATH) + + if(NOT MSVC AND NOT "${CMAKE_GENERATOR}" MATCHES "Makefiles") + foreach(_config ${CMAKE_CONFIGURATION_TYPES}) + get_target_property(_path${_config} ${_target} LOCATION_${_config}) + get_filename_component(_path${_config} "${_path${_config}}" PATH) + add_custom_command(TARGET ${_target} + POST_BUILD + COMMAND + ${CMAKE_COMMAND} + ARGS -E make_directory "${_path${_config}}/" + COMMENT "Creating directory ${_path${_config}}/") + endforeach() + endif() + + foreach(_res ${_resources}) + if(NOT IS_ABSOLUTE "${_res}") + get_filename_component(_res "${_res}" ABSOLUTE) + endif() + get_filename_component(_name "${_res}" NAME) + + if(MSVC) + # Working dir is solution file dir, not exe file dir. + add_custom_command(TARGET ${_target} + POST_BUILD + COMMAND + ${CMAKE_COMMAND} + ARGS -E copy "${_res}" "${CMAKE_BINARY_DIR}/" + COMMENT "Copying ${_name} to ${CMAKE_BINARY_DIR}/ for MSVC") + else() + if("${CMAKE_GENERATOR}" MATCHES "Makefiles") + add_custom_command(TARGET ${_target} + POST_BUILD + COMMAND + ${CMAKE_COMMAND} + ARGS -E copy "${_res}" "${_path}/" + COMMENT "Copying ${_name} to ${_path}/") + else() + foreach(_config ${CMAKE_CONFIGURATION_TYPES}) + add_custom_command(TARGET ${_target} + POST_BUILD + COMMAND + ${CMAKE_COMMAND} + ARGS -E copy "${_res}" "${_path${_config}}" + COMMENT "Copying ${_name} to ${_path${_config}}") + endforeach() + + endif() + endif() + endforeach() +endfunction() -- cgit v1.2.3