diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-04 20:09:33 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-15 18:22:20 +0200 |
commit | 0a63d31385cca2c352b5aa5288a902b140e9784f (patch) | |
tree | 592f73773dbf587415f6fc45ca9514ba091d773f | |
parent | 489f592ccb0b124e709ff26e16da1f745b029032 (diff) |
Update template to the reference
Change-Id: I20dbf83d4de0986c0b5d9aa2322f9f2450449037
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | templates/html5/CMakeLists.txt | 2 | ||||
-rw-r--r-- | templates/html5/app/CMakeLists.txt | 3 | ||||
-rw-r--r-- | templates/html5/etc/macros.cmake | 136 | ||||
-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 | ||||
-rw-r--r-- | templates/native/CMakeLists.txt | 5 | ||||
-rw-r--r-- | templates/native/etc/macros.cmake | 136 | ||||
-rw-r--r-- | templates/service/CMakeLists.txt | 4 | ||||
-rw-r--r-- | templates/service/etc/macros.cmake | 136 |
11 files changed, 262 insertions, 304 deletions
diff --git a/templates/html5/CMakeLists.txt b/templates/html5/CMakeLists.txt index 26b9226..bc9558e 100644 --- a/templates/html5/CMakeLists.txt +++ b/templates/html5/CMakeLists.txt @@ -21,6 +21,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.3) include(${CMAKE_CURRENT_SOURCE_DIR}/etc/config.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/etc/macros.cmake) -search_targets() +project_subdirs_add() build_widget() diff --git a/templates/html5/app/CMakeLists.txt b/templates/html5/app/CMakeLists.txt index ec66f01..80bb600 100644 --- a/templates/html5/app/CMakeLists.txt +++ b/templates/html5/app/CMakeLists.txt @@ -31,8 +31,5 @@ PROJECT_TARGET_ADD(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/html5/etc/macros.cmake b/templates/html5/etc/macros.cmake index 6a389de..a002d95 100644 --- a/templates/html5/etc/macros.cmake +++ b/templates/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) 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) diff --git a/templates/native/CMakeLists.txt b/templates/native/CMakeLists.txt index 0361f72..c40f0ca 100644 --- a/templates/native/CMakeLists.txt +++ b/templates/native/CMakeLists.txt @@ -37,7 +37,6 @@ PROJECT_TARGET_ADD(native-example) # Binder exposes a unique public entry point SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - PREFIX "" LABELS "EXECUTABLE" OUTPUT_NAME ${TARGET_NAME}) @@ -50,6 +49,6 @@ PROJECT_TARGET_ADD(native-example) afbwsc ${link_libraries}) -populate_widget() +project_targets_populate() -build_widget() +project_package_build() diff --git a/templates/native/etc/macros.cmake b/templates/native/etc/macros.cmake index 6a389de..a002d95 100644 --- a/templates/native/etc/macros.cmake +++ b/templates/native/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) diff --git a/templates/service/CMakeLists.txt b/templates/service/CMakeLists.txt index ea06ed0..a0faf48 100644 --- a/templates/service/CMakeLists.txt +++ b/templates/service/CMakeLists.txt @@ -35,6 +35,6 @@ PROJECT_TARGET_ADD(service-example) LABELS "BINDING" OUTPUT_NAME ${TARGET_NAME}) -populate_widget() +project_targets_populate() -build_widget() +project_package_build() diff --git a/templates/service/etc/macros.cmake b/templates/service/etc/macros.cmake index 6a389de..a002d95 100644 --- a/templates/service/etc/macros.cmake +++ b/templates/service/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) |