diff --git a/cmake/common.cmake b/cmake/common.cmake index 385f457dd589454775507f2c8be87df5b5d356d0..e863bf93391833d1548cc182c852e10428096e05 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 a7b1fdf114599a4bee0a153c7a3b279492ff7fee..68fa6695c815ac7f2c2c4fbfae6c77eb7a9aa5a3 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.