summaryrefslogtreecommitdiffstats
path: root/CAN-binder/etc/macros.cmake
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-09 16:43:08 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-09 16:43:08 +0200
commit098854d18568a2ea17f47a3711d3f74bdafb4c3e (patch)
tree22eb3f743b783aab1a99e774e3a9e83d6c051d6e /CAN-binder/etc/macros.cmake
parentc5869548e87c8b8cba4b41a80d2b9580e3d5b242 (diff)
Update CMake to the reference app-template. WIP
Change-Id: Icbab921e8ae3380c09cf5b2f5e7f4ba4a59e4c6e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/etc/macros.cmake')
-rw-r--r--CAN-binder/etc/macros.cmake53
1 files changed, 37 insertions, 16 deletions
diff --git a/CAN-binder/etc/macros.cmake b/CAN-binder/etc/macros.cmake
index 184f8ba..9d34aa7 100644
--- a/CAN-binder/etc/macros.cmake
+++ b/CAN-binder/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()