-# Dumb macro to add each directory under a path. Make sure we grab all header files!
-macro(fill_include_dir path)
- file(GLOB_RECURSE dirlist LIST_DIRECTORIES true "${path}/*")
- foreach(filename ${dirlist})
- if(IS_DIRECTORY ${filename})
- include_directories(${filename})
- endif(IS_DIRECTORY ${filename})
- endforeach()
-endmacro(fill_include_dir)
-
-# Helper function to retrieve source files from a library repo.
-function(find_source_files path)
- file(GLOB_RECURSE cfiles "${path}/*.[c]")
- file(GLOB_RECURSE cppfiles "${path}/*.cpp")
- foreach(filename ${cfiles})
- if(NOT ${filename} MATCHES ".*([Tt]est|[Ee]xample|[Ss]ample).*")
- string(APPEND sources "${filename};")
- endif(NOT ${filename} MATCHES ".*([Tt]est|[Ee]xample|[Ss]ample).*")
- endforeach()
- foreach(filename ${cppfiles})
- if(NOT ${filename} MATCHES ".*([Tt]est|[Ee]xample|[Ss]ample).*")
- string(APPEND sources "${filename};")
- endif(NOT ${filename} MATCHES ".*([Tt]est|[Ee]xample|[Ss]ample).*")
+# WGT packaging
+macro(project_targets_populate)
+ foreach(TARGET ${PROJECT_TARGETS})
+ get_target_property(T ${TARGET} LABELS)
+ if(T)
+ # Declaration of a custom command that will populate widget tree with the target
+ set(POPULE_WIDGET_TARGET "project_populate_${TARGET}")
+
+ get_target_property(P ${TARGET} PREFIX)
+ get_target_property(BD ${TARGET} BINARY_DIR)
+ get_target_property(OUT ${TARGET} OUTPUT_NAME)
+
+ if(P MATCHES "NOTFOUND$")
+ if (${T} STREQUAL "BINDING")
+ set(P "lib")
+ else()
+ set(P "")
+ endif()
+ endif()
+
+ if(${T} STREQUAL "BINDING")
+ add_custom_command(OUTPUT ${WIDGET_LIBDIR}/${P}${TARGET}.so
+ DEPENDS ${TARGET}
+ COMMAND mkdir -p ${WIDGET_LIBDIR}
+ COMMAND cp ${BD}/${P}${OUT}.so ${WIDGET_LIBDIR}
+ )
+ add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_LIBDIR}/${P}${TARGET}.so)
+ elseif(${T} STREQUAL "EXECUTABLE")
+ add_custom_command(OUTPUT ${WIDGET_BINDIR}/${P}${TARGET}
+ DEPENDS ${TARGET}
+ COMMAND mkdir -p ${WIDGET_BINDIR}
+ COMMAND cp ${BD}/${P}${OUT} ${WIDGET_BINDIR}
+ )
+ add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_BINDIR}/${P}${TARGET})
+ elseif(${T} STREQUAL "HTDOCS")
+ add_custom_command(OUTPUT ${WIDGET_HTTPDIR}
+ DEPENDS ${TARGET}
+ COMMAND cp -r ${BD}/${P}${OUT} ${WIDGET_HTTPDIR}
+ )
+ add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_HTTPDIR})
+ elseif(${T} STREQUAL "DATA")
+ add_custom_command(OUTPUT ${WIDGET_DATADIR}
+ DEPENDS ${TARGET}
+ COMMAND cp -r ${BD}/${P}${OUT} ${WIDGET_DATADIR}
+ )
+ add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_HTTPDIR})
+ endif(${T} STREQUAL "BINDING")
+ PROJECT_TARGET_ADD(${POPULE_WIDGET_TARGET})
+# elseif(${CMAKE_BUILD_TYPE} MATCHES "[Dd][Ee][Bb][Uu][Gg]")
+# MESSAGE(AUTHOR_WARNING "This target, ${TARGET}, will be not be included in the package.")
+ endif()