diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-04 20:09:33 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-04 20:09:33 +0200 |
commit | 5ada5e9225122f2c51277e1816a52a4a6ff79ec7 (patch) | |
tree | aa0e5970999f8ed621f842964c9f64809911297f /templates/hybrid-html5 | |
parent | 453eaf61f02b19b7fa5ac3f71243ca9d5ee63317 (diff) |
Update template to the reference
Change-Id: I20dbf83d4de0986c0b5d9aa2322f9f2450449037
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'templates/hybrid-html5')
-rw-r--r-- | templates/hybrid-html5/CMakeLists.txt | 2 | ||||
-rw-r--r-- | templates/hybrid-html5/app/CMakeLists.txt | 3 | ||||
-rw-r--r-- | templates/hybrid-html5/binding/CMakeLists.txt | 3 | ||||
-rw-r--r-- | templates/hybrid-html5/etc/macros.cmake | 136 |
4 files changed, 65 insertions, 79 deletions
diff --git a/templates/hybrid-html5/CMakeLists.txt b/templates/hybrid-html5/CMakeLists.txt index 1e44569..b153bf0 100644 --- a/templates/hybrid-html5/CMakeLists.txt +++ b/templates/hybrid-html5/CMakeLists.txt @@ -22,6 +22,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/etc/config.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/etc/macros.cmake) # Add subdir targets -search_targets() +project_subdirs_add() build_widget() diff --git a/templates/hybrid-html5/app/CMakeLists.txt b/templates/hybrid-html5/app/CMakeLists.txt index a862b3c..b4019c7 100644 --- a/templates/hybrid-html5/app/CMakeLists.txt +++ b/templates/hybrid-html5/app/CMakeLists.txt @@ -31,8 +31,5 @@ PROJECT_TARGET_ADD(hybrid-html5-example) # Binder exposes a unique public entry point SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - PREFIX "" LABELS "HTDOCS" OUTPUT_NAME dist.prod) - -populate_widget() diff --git a/templates/hybrid-html5/binding/CMakeLists.txt b/templates/hybrid-html5/binding/CMakeLists.txt index 10f4de8..e07ee5a 100644 --- a/templates/hybrid-html5/binding/CMakeLists.txt +++ b/templates/hybrid-html5/binding/CMakeLists.txt @@ -25,7 +25,6 @@ PROJECT_TARGET_ADD(xxxxxx-hybrid-binding) # Binder exposes a unique public entry point SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - PREFIX "" LABELS "BINDING" LINK_FLAGS ${BINDINGS_LINK_FLAG} OUTPUT_NAME ${TARGET_NAME} @@ -38,5 +37,3 @@ PROJECT_TARGET_ADD(xxxxxx-hybrid-binding) # installation directory INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) - - populate_widget() diff --git a/templates/hybrid-html5/etc/macros.cmake b/templates/hybrid-html5/etc/macros.cmake index 6a389de..a002d95 100644 --- a/templates/hybrid-html5/etc/macros.cmake +++ b/templates/hybrid-html5/etc/macros.cmake @@ -19,7 +19,7 @@ #-------------------------------------------------------------------------- -# WARNING: +# WARNING: # Do not change this cmake template # Customise your preferences in "./etc/config.cmake" #-------------------------------------------------------------------------- @@ -36,73 +36,60 @@ macro(defstr name value) add_definitions(-D${name}=${value}) endmacro(defstr) -# 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).*") - endforeach() - set(sources_files ${sources} PARENT_SCOPE) -endfunction(find_source_files) - # WGT packaging -macro(populate_widget) - # Declaration of a custom command that will populate widget tree with the target - set(POPULE_WIDGET_TARGET "populate_${TARGET_NAME}") - - get_target_property(T ${TARGET_NAME} LABELS) - get_target_property(OUT ${TARGET_NAME} OUTPUT_NAME) - - if(${T} STREQUAL "BINDING") - add_custom_command(OUTPUT ${WIDGET_LIBDIR}/${TARGET_NAME}.so - DEPENDS ${TARGET_NAME} - COMMAND mkdir -p ${WIDGET_LIBDIR} - COMMAND cp ${OUT}.so ${WIDGET_LIBDIR} - ) - add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_LIBDIR}/${TARGET_NAME}.so) - elseif(${T} STREQUAL "EXECUTABLE") - add_custom_command(OUTPUT ${WIDGET_BINDIR}/${TARGET_NAME} - DEPENDS ${TARGET_NAME} - COMMAND mkdir -p ${WIDGET_BINDIR} - COMMAND cp ${OUT} ${WIDGET_BINDIR} - ) - add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_BINDIR}/${TARGET_NAME}) - elseif(${T} STREQUAL "HTDOCS") - add_custom_command(OUTPUT ${WIDGET_HTTPDIR} - DEPENDS ${TARGET_NAME} - COMMAND cp -r ${OUT} ${WIDGET_HTTPDIR} +macro(project_targets_populate) + foreach(TARGET ${PROJECT_TARGETS}) + # Declaration of a custom command that will populate widget tree with the target + set(POPULE_WIDGET_TARGET "project_populate_${TARGET}") + + get_target_property(T ${TARGET} LABELS) + get_target_property(P ${TARGET} PREFIX) + get_target_property(BD ${TARGET} BINARY_DIR) + get_target_property(OUT ${TARGET} OUTPUT_NAME) + + if(${P} STREQUAL "P-NOTFOUND" AND ${T} STREQUAL "BINDING") + set(P "lib") + elseif(${P} STREQUAL "P-NOTFOUND") + set(P "") + endif(${P} STREQUAL "P-NOTFOUND" AND ${T} STREQUAL "BINDING") + + 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_HTTPDIR}) - elseif(${T} STREQUAL "DATA") - add_custom_command(OUTPUT ${WIDGET_DATADIR} - DEPENDS ${TARGET_NAME} - COMMAND cp -r ${OUT} ${WIDGET_DATADIR} + 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_HTTPDIR}) - endif(${T} STREQUAL "BINDING") - PROJECT_TARGET_ADD(${POPULE_WIDGET_TARGET}) -endmacro(populate_widget) + 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}) + else() + if(${CMAKE_BUILD_TYPE} MATCHES "[Dd][Ee][Bb][Uu][Gg]") + MESSAGE(AUTHOR_WARNING "This target, ${TARGET}, will be not be included in the package.") + endif(${CMAKE_BUILD_TYPE} MATCHES "[Dd][Ee][Bb][Uu][Gg]") + endif(${T} STREQUAL "BINDING") + PROJECT_TARGET_ADD(${POPULE_WIDGET_TARGET}) + endforeach() +endmacro(project_targets_populate) -macro(build_widget) - if("${PROJECT_TARGETS}" MATCHES "populate_") +macro(project_package_build) + if("${PROJECT_TARGETS}" MATCHES "project_populate_") if(NOT EXISTS ${WIDGET_DIR}/config.xml.in OR NOT EXISTS ${WIDGET_DIR}/${PROJECT_ICON}.in) configure_file(${PROJECT_WGT_DIR}/config.xml.in ${WIDGET_DIR}/config.xml) file(COPY ${PROJECT_WGT_DIR}/${PROJECT_ICON}.in DESTINATION ${WIDGET_DIR}/${PROJECT_ICON}) @@ -121,17 +108,22 @@ macro(build_widget) set(ADDITIONAL_MAKE_CLEAN_FILES, "${PROJECT_NAME}.wgt") else() MESSAGE(FATAL_ERROR "Widget tree empty, please populate it by calling populate_widget() macro with target you want to include into it.") - endif("${PROJECT_TARGETS}" MATCHES "populate_") -endmacro(build_widget) + endif("${PROJECT_TARGETS}" MATCHES "project_populate_") +endmacro(project_package_build) + +macro(project_subdirs_add) + if(${ARGV0}) + file(GLOB filelist "${ARGV0}") + else() + file(GLOB filelist "*") + endif(${ARGV0}) -macro(search_targets) - file(GLOB filelist "*") foreach(filename ${filelist}) - if(EXISTS "${filename}/CMakeLists.txt") - add_subdirectory(${filename}) - endif(EXISTS "${filename}/CMakeLists.txt") + if(EXISTS "${filename}/CMakeLists.txt") + add_subdirectory(${filename}) + endif(EXISTS "${filename}/CMakeLists.txt") endforeach() -endmacro() +endmacro(project_subdirs_add) set(CMAKE_BUILD_TYPE Debug CACHE STRING "the type of build") set(CMAKE_POSITION_INDEPENDENT_CODE ON) |