aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--CAN-binder/CMakeLists.txt8
-rw-r--r--CAN-binder/etc/config.cmake16
-rw-r--r--CAN-binder/etc/macros.cmake (renamed from CAN-binder/etc/agl.cmake)55
-rw-r--r--CAN-binder/low-can-binding/CMakeLists.txt35
-rw-r--r--CAN-binder/low-can-demo/CMakeLists.txt45
-rw-r--r--CAN-binder/packaging/wgt/config.xml.in2
-rw-r--r--CAN-binder/packaging/wgt/etc/can_buses.json3
-rw-r--r--CAN-binder/packaging/wgt/package.in4
8 files changed, 114 insertions, 54 deletions
diff --git a/CAN-binder/CMakeLists.txt b/CAN-binder/CMakeLists.txt
index 302222e3..56e7860f 100644
--- a/CAN-binder/CMakeLists.txt
+++ b/CAN-binder/CMakeLists.txt
@@ -17,6 +17,12 @@
###########################################################################
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
-include(${CMAKE_CURRENT_SOURCE_DIR}/etc/agl.cmake)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/etc/config.cmake)
+include(${CMAKE_CURRENT_SOURCE_DIR}/etc/macros.cmake)
+
+# Bindings to compile
+# --------------------
+search_targets()
build_widget()
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)
diff --git a/CAN-binder/low-can-binding/CMakeLists.txt b/CAN-binder/low-can-binding/CMakeLists.txt
index ddac1db6..ded3be4c 100644
--- a/CAN-binder/low-can-binding/CMakeLists.txt
+++ b/CAN-binder/low-can-binding/CMakeLists.txt
@@ -21,17 +21,32 @@
PROJECT_TARGET_ADD(low-can-binding)
# Define project Targets
- add_library(${TARGET_NAME} MODULE ${TARGET_NAME}.cpp configuration.cpp configuration-generated.cpp
- can/can-bus.cpp can/can-bus-dev.cpp can/can-message-set.cpp can/can-message-definition.cpp can/can-message.cpp can/can-signals.cpp can/can-decoder.cpp
- diagnostic/diagnostic-message.cpp diagnostic/diagnostic-manager.cpp diagnostic/active-diagnostic-request.cpp
- utils/signals.cpp utils/openxc-utils.cpp utils/timer.cpp utils/socketcan.cpp utils/config-parser.cpp)
+ add_library(${TARGET_NAME} MODULE
+ ${TARGET_NAME}.cpp
+ configuration.cpp
+ configuration-generated.cpp
+ can/can-bus.cpp
+ can/can-bus-dev.cpp
+ can/can-message-set.cpp
+ can/can-message-definition.cpp
+ can/can-message.cpp
+ can/can-signals.cpp
+ can/can-decoder.cpp
+ diagnostic/diagnostic-message.cpp
+ diagnostic/diagnostic-manager.cpp
+ diagnostic/active-diagnostic-request.cpp
+ utils/signals.cpp
+ utils/openxc-utils.cpp
+ utils/timer.cpp
+ utils/socketcan.cpp
+ utils/config-parser.cpp)
# 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}
+ PREFIX ""
+ LABELS "BINDING"
+ LINK_FLAGS ${BINDINGS_LINK_FLAG}
+ OUTPUT_NAME ${TARGET_NAME}
)
# Library dependencies (include updates automatically)
@@ -44,8 +59,8 @@ PROJECT_TARGET_ADD(low-can-binding)
bitfield-c
${link_libraries})
- populate_widget()
-
# installation directory
INSTALL(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR})
+
+ populate_widget()
diff --git a/CAN-binder/low-can-demo/CMakeLists.txt b/CAN-binder/low-can-demo/CMakeLists.txt
new file mode 100644
index 00000000..a554598c
--- /dev/null
+++ b/CAN-binder/low-can-demo/CMakeLists.txt
@@ -0,0 +1,45 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: Fulup Ar Foll <fulup@iot.bzh>
+# contrib: Romain Forlot <romain.forlot@iot.bzh>w
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+# Add subdir targets
+search_targets()
+
+# Add target to project dependency list
+PROJECT_TARGET_ADD(low-can-demo)
+
+ # Define project Targets
+ add_custom_command(OUTPUT dist.prod
+ DEPENDS ${TARGET_NAME}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND npm install
+ COMMAND gulp build-app-prod
+ COMMAND cp -r dist.prod ${CMAKE_CURRENT_BINARY_DIR})
+
+ add_custom_target(${TARGET_NAME} ALL DEPENDS dist.prod)
+
+ # Binder exposes a unique public entry point
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ PREFIX ""
+ LABELS "HTDOCS"
+ OUTPUT_NAME dist.prod)
+
+ # installation directory
+ INSTALL(DIRECTORY dist.prod/ DESTINATION ${BINDINGS_INSTALL_DIR})
+
+ populate_widget() \ No newline at end of file
diff --git a/CAN-binder/packaging/wgt/config.xml.in b/CAN-binder/packaging/wgt/config.xml.in
index 5965904d..99c01687 100644
--- a/CAN-binder/packaging/wgt/config.xml.in
+++ b/CAN-binder/packaging/wgt/config.xml.in
@@ -3,7 +3,7 @@
<name>@PROJECT_NAME@</name>
<icon src="icon.png"/>
<content src="htdocs/index.html" type="application/vnd.agl.html.hybrid"/>
- <description>This is a demo application used with low-can binding.</description>
+ <description>@PROJECT_DESCRIPTION@</description>
<author>Romain Forlot &lt;romain.forlot@iot.bzh&gt;</author>
<license>APL 2.0</license>
</widget>
diff --git a/CAN-binder/packaging/wgt/etc/can_buses.json b/CAN-binder/packaging/wgt/etc/can_buses.json
new file mode 100644
index 00000000..c4292df2
--- /dev/null
+++ b/CAN-binder/packaging/wgt/etc/can_buses.json
@@ -0,0 +1,3 @@
+{
+ "canbus": "can0"
+}
diff --git a/CAN-binder/packaging/wgt/package.in b/CAN-binder/packaging/wgt/package.in
deleted file mode 100644
index 5e12032b..00000000
--- a/CAN-binder/packaging/wgt/package.in
+++ /dev/null
@@ -1,4 +0,0 @@
-can_buses.json
-low-can-demo/dist.prod
-low-can-demo/cpu-stat-binding.so
-low-can-binding/low-can-binding.so \ No newline at end of file