-endmacro(remote_targets_populate)
-
-macro(wgt_package_build)
- if(NOT EXISTS ${TEMPLATE_WGT_DIR}/config.xml.in OR NOT EXISTS ${TEMPLATE_WGT_DIR}/icon-default.png)
- MESSAGE(SEND_ERROR "${Red}WARNING ! Missing mandatory files to build widget file.\nYou need config.xml.in and ${PROJECT_ICON} files in ${TEMPLATE_WGT_DIR} folder.${ColourReset}")
- else()
- # Build widget spec file from template only once (Fulup good idea or should depend on time ????)
- if(NOT EXISTS ${TEMPLATE_WGT_DIR}/config.xml.in OR NOT EXISTS ${TEMPLATE_WGT_DIR}/${PROJECT_ICON})
- configure_file(${TEMPLATE_WGT_DIR}/config.xml.in ${PROJECT_PKG_BUILD_DIR}/config.xml)
- configure_file(${TEMPLATE_WGT_DIR}/config.xml.in ${PROJECT_PKG_ENTRY_POINT}/config.xml)
- file(COPY ${TEMPLATE_WGT_DIR}/icon-default.png DESTINATION ${PROJECT_PKG_BUILD_DIR}/${PROJECT_ICON})
- endif(NOT EXISTS ${TEMPLATE_WGT_DIR}/config.xml.in OR NOT EXISTS ${TEMPLATE_WGT_DIR}/${PROJECT_ICON})
-
- # Fulup ??? copy any extra file in wgt/etc into populate package before building the widget
- file(GLOB PROJECT_CONF_FILES "${TEMPLATE_WGT_DIR}/etc/*")
- if(${PROJECT_CONF_FILES})
- file(COPY "${TEMPLATE_WGT_DIR}/etc/*" DESTINATION ${PROJECT_PKG_BUILD_DIR}/etc/)
- endif(${PROJECT_CONF_FILES})
-
- add_custom_command(OUTPUT ${PROJECT_NAME}.wgt
- DEPENDS ${PROJECT_TARGETS}
- COMMAND wgtpkg-pack -f -o ${PROJECT_NAME}.wgt ${PROJECT_PKG_BUILD_DIR}
- )
-
- add_custom_target(widget DEPENDS ${PROJECT_NAME}.wgt)
- add_dependencies(widget populate)
- set(ADDITIONAL_MAKE_CLEAN_FILES, "${PROJECT_NAME}.wgt")
-
- if(PACKAGE_MESSAGE)
- add_custom_command(TARGET widget
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "++ ${PACKAGE_MESSAGE}")
- endif()
- endif()
-endmacro(wgt_package_build)
-
-macro(rpm_package_build)
- if(NOT EXISTS ${TEMPLATE_RPM_DIR}/config.spec.in)
- MESSAGE(STATUS "Missing mandatory files: you need config.spec.in in ${TEMPLATE_RPM_DIR} folder.")
- else()
- # extract PROJECT_PKG_DEPS and replace ; by , for RPM spec file
- get_property(PROJECT_PKG_DEPS GLOBAL PROPERTY PROJECT_PKG_DEPS)
- foreach (PKFCONF ${PROJECT_PKG_DEPS})
- set(RPM_PKG_DEPS "${RPM_PKG_DEPS}, pkgconfig(${PKFCONF})")
- endforeach()
-
- # build rpm spec file from template
- configure_file(${TEMPLATE_RPM_DIR}/config.spec.in ${PROJECT_PKG_BUILD_DIR}/config.spec)
-
- add_custom_command(OUTPUT ${PROJECT_NAME}.spec
- DEPENDS ${PROJECT_TARGETS}
- COMMAND rpmbuild -ba ${PROJECT_PKG_BUILD_DIR}/config.spec
- )
-
- add_custom_target(rpm DEPENDS ${PROJECT_NAME}.spec)
- add_dependencies(rpm populate)
- set(ADDITIONAL_MAKE_CLEAN_FILES, "${PROJECT_NAME}.spec")
-
- if(PACKAGE_MESSAGE)
- add_custom_command(TARGET rpm
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "++ ${PACKAGE_MESSAGE}")
- endif()
- endif()
-endmacro(rpm_package_build)
-
-macro(project_package_build)
- if(EXISTS ${TEMPLATE_RPM_DIR})
- rpm_package_build()
- endif()
-
- if(EXISTS ${TEMPLATE_WGT_DIR})
- wgt_package_build()
- endif()
-
- if(EXISTS ${TEMPLATE_DEB_DIR})
- deb_package_build()
- endif()
-endmacro(project_package_build)
-
-macro(project_subdirs_add)
- set (ARGSLIST ${ARGN})
- list(LENGTH ARGSLIST ARGSNUM)
- if(${ARGSNUM} GREATER 0)
- file(GLOB filelist "${ARGV0}")
- else()
- file(GLOB filelist "*")
- endif()
-
- foreach(filename ${filelist})
- if(EXISTS "${filename}/CMakeLists.txt")
- add_subdirectory(${filename})
- endif(EXISTS "${filename}/CMakeLists.txt")
- endforeach()
-endmacro(project_subdirs_add)
-
-set(CMAKE_BUILD_TYPE Debug CACHE STRING "the type of build")
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-set(CMP0048 1)
-
-# Include project configuration
-# ------------------------------
-project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES})
-set(PROJECT_LIBDIR "${CMAKE_SOURCE_DIR}/libs" CACHE PATH "Subpath to libraries")
-set(PROJECT_RESOURCES "${CMAKE_SOURCE_DIR}/data" CACHE PATH "Subpath to data")
-
-set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN")
-set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
-
-INCLUDE(FindPkgConfig)
-INCLUDE(CheckIncludeFiles)
-INCLUDE(CheckLibraryExists)
-INCLUDE(GNUInstallDirs)
-
-# Default compilation options
-############################################################################
-link_libraries(-Wl,--as-needed -Wl,--gc-sections)
-add_compile_options(-Wall -Wextra -Wconversion)
-add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
-add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
-add_compile_options(-Werror=maybe-uninitialized)
-add_compile_options(-Werror=implicit-function-declaration)
-add_compile_options(-ffunction-sections -fdata-sections)
-add_compile_options(-fPIC)
-add_compile_options(-g)
-
-set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE" CACHE STRING "Flags for profiling")
-set(CMAKE_C_FLAGS_DEBUG "-g -O2 -ggdb -Wp,-U_FORTIFY_SOURCE" CACHE STRING "Flags for debugging")
-set(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "Flags for releasing")
-set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage" CACHE STRING "Flags for coverage test")