aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/etc
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-02 17:21:20 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-02 17:21:20 +0200
commit09e762b94a941c9b6f2402c6ea8bf444e13c1574 (patch)
tree13a999a79e4b7776fa3537d45c2e403271ad196a /CAN-binder/etc
parent39c3d1c6e78ee2f85b713dec39946c05709c1076 (diff)
Using new CMake architecture (again...)
Following the new CMake template from https://gerrit.automotivelinux.org/gerrit/apps/app-templates these CMake files use helpers macros from macros.cmake and project configuration config.cmake. Change-Id: I2297b6ad6c65cd763d1870d5b62564e8795f4317 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/etc')
-rw-r--r--CAN-binder/etc/config.cmake16
-rw-r--r--CAN-binder/etc/macros.cmake (renamed from CAN-binder/etc/agl.cmake)55
2 files changed, 33 insertions, 38 deletions
diff --git a/CAN-binder/etc/config.cmake b/CAN-binder/etc/config.cmake
index ac06926a..54f25da8 100644
--- a/CAN-binder/etc/config.cmake
+++ b/CAN-binder/etc/config.cmake
@@ -20,14 +20,14 @@
# ------------------
set(NAME low-can-project)
set(VERSION "1.0")
-set(PRETTY_NAME "Low level CAN binding")
-set(DESCRIPTION "Expose CAN Low Level APIs through AGL Framework")
-set(URL "https://github.com/iotbzh/CAN_signaling")
+set(PROJECT_PRETTY_NAME "Low level CAN binding")
+set(PROJECT_DESCRIPTION "Expose CAN Low Level APIs through AGL Framework")
+set(PROJECT_URL "https://github.com/iotbzh/CAN_signaling")
set(PROJECT_ICON "icon.png")
# Compilation Mode (DEBUG, RELEASE)
# ----------------------------------
-setc(CMAKE_BUILD_TYPE "DEBUG")
+set(CMAKE_BUILD_TYPE "DEBUG")
# Compiler selection if needed. Overload the detected compiler.
# -----------------------------------------------
@@ -53,14 +53,14 @@ set(CMAKE_CXX_FLAGS "-std=c++11")
# Print a helper message when every thing is finished
# ----------------------------------------------------
-setc(CLOSING_MESSAGE "Test with: afb-daemon --rootdir=\$\$(pwd)/low-can-binding/package --ldpaths=\$\$(pwd)/low-can-binding/package/lib --port=1234 --roothttp=\$\$(pwd)/low-can-binding/package/htdocs --tracereq=common --token=\"\" --verbose")
+set(CLOSING_MESSAGE "Test with: afb-daemon --rootdir=\$\$(pwd)/low-can-binding/package --ldpaths=\$\$(pwd)/low-can-binding/package/lib --port=1234 --roothttp=\$\$(pwd)/low-can-binding/package/htdocs --tracereq=common --token=\"\" --verbose")
# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable]
# ---------------------------------------------------------------------
-setc(CMAKE_INSTALL_PREFIX ${HOME}/opt)
-setc(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
-setc(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib)
+set(CMAKE_INSTALL_PREFIX ${HOME}/opt)
+set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
+set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib)
# Optional dependencies order
# ---------------------------
diff --git a/CAN-binder/etc/agl.cmake b/CAN-binder/etc/macros.cmake
index b05a2734..7bacc7f5 100644
--- a/CAN-binder/etc/agl.cmake
+++ b/CAN-binder/etc/macros.cmake
@@ -73,6 +73,7 @@ endfunction(find_source_files)
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)
if(${T} STREQUAL "BINDING")
add_custom_command(OUTPUT ${WIDGET_LIBDIR}/${TARGET_NAME}.so
@@ -81,44 +82,51 @@ macro(populate_widget)
COMMAND cp ${TARGET_NAME}.so ${WIDGET_LIBDIR}
)
add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_LIBDIR}/${TARGET_NAME}.so)
- endif(${T} STREQUAL "BINDING")
-
- if(${T} STREQUAL "EXECUTABLE")
+ elseif(${T} STREQUAL "EXECUTABLE")
add_custom_command(OUTPUT ${WIDGET_BINDIR}/${TARGET_NAME}
DEPENDS ${TARGET_NAME}
COMMAND mkdir -p ${WIDGET_BINDIR}
COMMAND cp ${TARGET_NAME} ${WIDGET_BINDIR}
)
add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_BINDIR}/${TARGET_NAME})
- endif(${T} STREQUAL "EXECUTABLE")
-
- if(${T} STREQUAL "HTDOCS")
+ elseif(${T} STREQUAL "HTDOCS")
get_target_property(OUT ${TARGET_NAME} OUTPUT_NAME)
- MESSAGE(STATUS "${OUT}")
add_custom_command(OUTPUT ${WIDGET_HTTPDIR}
DEPENDS ${TARGET_NAME}
COMMAND cp -r ${OUT} ${WIDGET_HTTPDIR}
)
add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_HTTPDIR})
- endif(${T} STREQUAL "HTDOCS")
-
- if(${T} STREQUAL "DATA")
+ elseif(${T} STREQUAL "DATA")
get_target_property(OUT ${TARGET_NAME} OUTPUT_NAME)
- MESSAGE(STATUS "${OUT}")
add_custom_command(OUTPUT ${WIDGET_DATADIR}
DEPENDS ${TARGET_NAME}
COMMAND cp -r ${OUT} ${WIDGET_DATADIR}
)
add_custom_target(${POPULE_WIDGET_TARGET} ALL DEPENDS ${WIDGET_HTTPDIR})
- endif(${T} STREQUAL "DATA")
-
+ endif(${T} STREQUAL "BINDING")
+ PROJECT_TARGET_ADD(${POPULE_WIDGET_TARGET})
endmacro(populate_widget)
macro(build_widget)
- if(NOT EXISTS ${WIDGET_DIR}/config.xml OR NOT EXISTS ${WIDGET_DIR}/icon.png)
- configure_file(${PROJECT_WGT_DIR}/config.xml.in ${WIDGET_DIR}/config.xml)
- #file(COPY ${PROJECT_WGT_DIR}/icon.png.in ${WIDGET_DIR}/icon.png)
- endif(NOT EXISTS ${WIDGET_DIR}/config.xml OR NOT EXISTS ${WIDGET_DIR}/icon.png)
+ if("${PROJECT_TARGETS}" MATCHES "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})
+ endif(NOT EXISTS ${WIDGET_DIR}/config.xml.in OR NOT EXISTS ${WIDGET_DIR}/${PROJECT_ICON}.in)
+
+ file(GLOB PROJECT_CONF_FILES "${PROJECT_WGT_DIR}/etc/*")
+ if(${PROJECT_CONF_FILES})
+ file(COPY "${PROJECT_WGT_DIR}/etc/*" DESTINATION ${WIDGET_ETCDIR}/)
+ endif(${PROJECT_CONF_FILES})
+
+ add_custom_command(OUTPUT ${PROJECT_NAME}.wgt
+ DEPENDS ${PROJECT_TARGETS}
+ COMMAND wgtpkg-pack -f -o ${PROJECT_NAME}.wgt ${WIDGET_DIR}
+ )
+ add_custom_target(widget DEPENDS ${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)
macro(search_targets)
@@ -130,26 +138,17 @@ macro(search_targets)
endforeach()
endmacro()
-CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
setc(CMAKE_BUILD_TYPE Debug)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMP0048 1)
# Include project configuration
# ------------------------------
-include(${CMAKE_CURRENT_SOURCE_DIR}/etc/config.cmake)
project(${NAME} VERSION ${VERSION})
-setc(PROJECT_PRETTY_NAME "${PRETTY_NAME}")
-setc(PROJECT_DESCRIPTION "${DESCRIPTION}")
setc(PROJECT_WGT_DIR "packaging/wgt")
setc(PROJECT_LIBDIR "libs")
setc(PROJECT_RESOURCES "data")
-message(STATUS "")
-message(STATUS "Project=${PROJECT_NAME}/${VERSION}[${PRETTY_NAME} ${DESCRIPTION}]")
-message(STATUS "")
-message(STATUS "gcc/g++ version-${CMAKE_C_VERSION}.x selected")
-
INCLUDE(FindPkgConfig)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
@@ -230,10 +229,6 @@ if(NOT BINDINGS_LINK_FLAG)
set(BINDINGS_LINK_FLAG "-Wl,--version-script=${CMAKE_SOURCE_DIR}/etc/export.map")
endif()
-# Bindings to compile
-# --------------------
-search_targets()
-
# Add a dummy target to enable global dependency order
# -----------------------------------------------------
if(EXTRA_DEPENDENCIES_ORDER)