summaryrefslogtreecommitdiffstats
path: root/templates/native/etc/macros.cmake
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-09 13:20:38 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-10-15 18:22:20 +0200
commit1435f4c7f73a51e2a672287424dd0464726a0943 (patch)
tree3df57c69b6cbf5e78d26301ad249bc8b5834d1ac /templates/native/etc/macros.cmake
parent89ec4ab1ecbe8547bf58b8ae155ac3008e9b73fd (diff)
Update template with references.
Change-Id: Ic575adc4c8815f41a02c32d9835332cc2608d513 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'templates/native/etc/macros.cmake')
-rw-r--r--templates/native/etc/macros.cmake53
1 files changed, 37 insertions, 16 deletions
diff --git a/templates/native/etc/macros.cmake b/templates/native/etc/macros.cmake
index 184f8ba..9d34aa7 100644
--- a/templates/native/etc/macros.cmake
+++ b/templates/native/etc/macros.cmake
@@ -34,18 +34,27 @@ macro(PROJECT_TARGET_ADD TARGET_NAME)
# Cmake does not maintain targets list before 3.7
# -------------------------------------------------
if(${CMAKE_VERSION} VERSION_LESS 3.7)
- set(GLOBAL_TARGET_LIST ${PROJECT_TARGETS})
+ set(GLOBAL_TARGET_LIST ${PROJECT_TARGETS} CACHE INTERNAL "Hold project targets")
else()
get_property(GLOBAL_TARGET_LIST GLOBAL PROPERTY GlobalTargetList)
endif()
endmacro(PROJECT_TARGET_ADD)
+# Check GCC minimal version version
+if (gcc_minimal_version)
+ message ("-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) (found g++ version ${CMAKE_CXX_COMPILER_VERSION})")
+if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version} OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version})
+ message(FATAL_ERROR "**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER")
+endif()
+endif(gcc_minimal_version)
+
macro(defstr name value)
add_definitions(-D${name}=${value})
endmacro(defstr)
# WGT packaging
macro(project_targets_populate)
+ add_custom_target(MAIN_POPULATE)
foreach(TARGET ${PROJECT_TARGETS})
get_target_property(T ${TARGET} LABELS)
if(T)
@@ -70,36 +79,42 @@ macro(project_targets_populate)
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)
+ add_custom_target(${POPULE_WIDGET_TARGET} DEPENDS ${WIDGET_LIBDIR}/${P}${TARGET}.so)
+ add_dependencies(MAIN_POPULATE ${POPULE_WIDGET_TARGET})
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})
+ add_custom_target(${POPULE_WIDGET_TARGET} DEPENDS ${WIDGET_BINDIR}/${P}${TARGET})
+ add_dependencies(MAIN_POPULATE ${POPULE_WIDGET_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})
+ add_custom_target(${POPULE_WIDGET_TARGET} DEPENDS ${WIDGET_HTTPDIR})
+ add_dependencies(MAIN_POPULATE ${POPULE_WIDGET_TARGET})
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})
+ add_custom_target(${POPULE_WIDGET_TARGET} DEPENDS ${WIDGET_HTTPDIR})
+ add_dependencies(MAIN_POPULATE ${POPULE_WIDGET_TARGET})
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.")
+# MESSAGE(WARNING "This target, ${TARGET}, will be not be included in the package.")
endif()
endforeach()
endmacro(project_targets_populate)
macro(project_package_build)
- if("${PROJECT_TARGETS}" MATCHES "project_populate_")
+ if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR}/config.xml.in OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR}/${PROJECT_ICON}.in)
+ MESSAGE(FATAL_ERROR "Missing mandatory files: you need config.xml.in and ${PROJECT_ICON}.in files in ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_WGT_DIR} folder.")
+ endif()
+
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})
@@ -111,14 +126,19 @@ macro(project_package_build)
endif(${PROJECT_CONF_FILES})
add_custom_command(OUTPUT ${PROJECT_NAME}.wgt
- DEPENDS ${PROJECT_TARGETS}
- COMMAND wgtpkg-pack -f -o ${PROJECT_NAME}.wgt ${WIDGET_DIR}
+ DEPENDS ${PROJECT_TARGETS}
+ COMMAND wgtpkg-pack -f -o ${PROJECT_NAME}.wgt ${WIDGET_DIR}
)
+
add_custom_target(widget DEPENDS ${PROJECT_NAME}.wgt)
+ add_dependencies(widget MAIN_POPULATE)
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 "project_populate_")
+
+ if(WIDGET_MESSAGE)
+ add_custom_command(TARGET widget
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "++ ${WIDGET_MESSAGE}")
+ endif()
endmacro(project_package_build)
macro(project_subdirs_add)
@@ -235,13 +255,14 @@ if(EXTRA_DEPENDENCIES_ORDER)
)
endif()
-# Print developer helper message when everything is done
+# Print developer helper message when build is done
# -------------------------------------------------------
macro(project_closing_msg)
if(CLOSING_MESSAGE AND GLOBAL_TARGET_LIST)
- add_custom_target(${PROJECT_NAME}_done ALL
- DEPENDS ${DEPENDENCIES_TARGET} ${GLOBAL_TARGET_LIST}
+ add_custom_target(${PROJECT_NAME}_build_done ALL
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "++ ${CLOSING_MESSAGE}"
)
+ add_dependencies(${PROJECT_NAME}_build_done
+ ${DEPENDENCIES_TARGET} ${GLOBAL_TARGET_LIST})
endif()
endmacro()