From 754fdc453cc9bdf3094243d1abbf7935275297b8 Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Wed, 6 Aug 2014 09:57:51 +0000 Subject: [PATCH] Attempt at reducing the path length of INSTALLDATA targets. git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@19378 383ad7c9-94d9-4d36-a494-682f7c89f535 --- cmake/common.cmake | 46 ++++++++++++++++++++++++++++++++++++++++++++++ cmake/plugin.cmake | 7 +++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/cmake/common.cmake b/cmake/common.cmake index 385f457d..e863bf93 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -44,9 +44,55 @@ function (of_add_plugins) foreach (_plugin ${_plugins_in}) get_filename_component (_plugin_dir ${_plugin} PATH) + + # In INSTALLDATA_DIRS the resource directories will be handed down. + set(INSTALLDATA_DIRS) add_subdirectory (${CMAKE_SOURCE_DIR}/${_plugin_dir}) + + # Add targets for data dirs + if (INSTALLDATA_DIRS) + # Extract plugin name + string (REGEX MATCH "Plugin-.+[/\\]?$" _dir ${_plugin_dir}) + string (REPLACE "Plugin-" "" _plugin ${_dir}) + + # Crawl for resoruce files + set(DATA_FILES) + foreach (_dir ${INSTALLDATA_DIRS}) + set(dst "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/${_dir}") + set(src "${CMAKE_SOURCE_DIR}/${_plugin_dir}/${_dir}") + acg_unset (_files) + acg_get_files_in_dir (_files ${src}) + foreach (_file ${_files}) + add_custom_command(OUTPUT "${dst}/${_file}" + DEPENDS "${src}/${_file}" + COMMAND ${CMAKE_COMMAND} -E copy "${src}/${_file}" "${dst}/${_file}" + ) + # Collect command targets + list(APPEND DATA_FILES "${dst}/${_file}") + endforeach () + endforeach () + # Add custom target that will copy the files and make it a + # dependency of the plugin target. + add_custom_target(RSRC-${_plugin} DEPENDS ${DATA_FILES}) + add_dependencies(Plugin-${_plugin} RSRC-${_plugin}) + endif() endforeach () + + # Hand down loaded packages to caller. set(LOADED_PACKAGES ${LOADED_PACKAGES} PARENT_SCOPE) + +# #acg_copy_after_build (Plugin-${plugin} "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/${_dir}") +# +# set(OUTPUT_FILES "") +# add_custom_command(OUTPUT "${dst}/${_file}" +# DEPENDS "${src}/${_file}" +# COMMAND ${CMAKE_COMMAND} -E copy "${src}/${_file}" "${dst}/${_file}" +# ) +# list(APPEND OUTPUT_FILES "${dst}/${_file}") +# get_filename_component(BASENAME "${dst}" NAME) +# add_custom_target("${target}_CPY_${BASENAME}" DEPENDS ${OUTPUT_FILES}) +# add_dependencies(${target} "${target}_CPY_${BASENAME}") + endfunction () macro(_get_plugin_name _path _name) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index a7b1fdf1..68fa6695 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -624,12 +624,14 @@ function (_build_openflipper_plugin plugin) ) endif () + set(INSTALLDATA_DIRS) foreach (_dir ${${_PLUGIN}_INSTALLDATA}) - acg_copy_after_build (Plugin-${plugin} "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/${_dir}") + list(APPEND INSTALLDATA_DIRS "${_dir}") if (NOT APPLE) acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" "${ACG_PROJECT_DATADIR}/${_dir}") endif () endforeach () + set(INSTALLDATA_DIRS ${INSTALLDATA_DIRS} PARENT_SCOPE) #============================================================================================ # CUDA Integration @@ -719,8 +721,9 @@ macro (openflipper_plugin) if (NOT DISABLE_PLUGIN_${_PLUGIN}) _build_openflipper_plugin (${_plugin} ${ARGN}) + set(LOADED_PACKAGES ${LOADED_PACKAGES} PARENT_SCOPE) + set(INSTALLDATA_DIRS ${INSTALLDATA_DIRS} PARENT_SCOPE) endif () - set(LOADED_PACKAGES ${LOADED_PACKAGES} PARENT_SCOPE) endmacro () # No stupid abundance of "Boost version" messages, please. -- GitLab