From 21152e00db30d00b529b3843b2cbed7116ea4eb3 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 29 Mar 2014 15:31:06 +0400 Subject: [PATCH] Renamed dsdlc target, library made static, added linux drivers project (empty yet) --- libuavcan/CMakeLists.txt | 10 ++++----- libuavcan_drivers/linux/CMakeLists.txt | 22 +++++++++++++++++++ libuavcan_drivers/linux/cppcheck.sh | 11 ++++++++++ .../linux/include/uavcan_linux/clock.hpp | 1 + .../linux/include/uavcan_linux/socketcan.hpp | 1 + .../linux/test/log_subscriber.cpp | 14 ++++++++++++ 6 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 libuavcan_drivers/linux/CMakeLists.txt create mode 100755 libuavcan_drivers/linux/cppcheck.sh create mode 100644 libuavcan_drivers/linux/include/uavcan_linux/clock.hpp create mode 100644 libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp create mode 100644 libuavcan_drivers/linux/test/log_subscriber.cpp diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 67cb592181..d0ab3e11e5 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -34,7 +34,7 @@ endif () execute_process(COMMAND ./setup.py build WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dsdl_compiler) set(DSDLC_INPUTS "test/dsdl_test/root_ns_a" "test/dsdl_test/root_ns_b" "${CMAKE_CURRENT_SOURCE_DIR}/../dsdl/uavcan") set(DSDLC_OUTPUT "include/dsdlc_generated") -add_custom_target(dsdlc dsdl_compiler/libuavcan_dsdlc ${DSDLC_INPUTS} -O${DSDLC_OUTPUT} +add_custom_target(libuavcan_dsdlc dsdl_compiler/libuavcan_dsdlc ${DSDLC_INPUTS} -O${DSDLC_OUTPUT} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${DSDLC_OUTPUT}) @@ -62,8 +62,8 @@ include_directories(include) # libuavcan # file(GLOB_RECURSE LIBUAVCAN_CXX_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") -add_library(uavcan SHARED ${LIBUAVCAN_CXX_FILES}) -add_dependencies(uavcan dsdlc) +add_library(uavcan STATIC ${LIBUAVCAN_CXX_FILES}) +add_dependencies(uavcan libuavcan_dsdlc) install(TARGETS uavcan DESTINATION lib) install(DIRECTORY include/uavcan DESTINATION include) @@ -111,11 +111,11 @@ if (DEBUG_BUILD) # Additional flavours of the library add_library(uavcan_cpp03 SHARED ${LIBUAVCAN_CXX_FILES}) set_target_properties(uavcan_cpp03 PROPERTIES COMPILE_FLAGS ${cpp03_flags}) - add_dependencies(uavcan_cpp03 dsdlc) + add_dependencies(uavcan_cpp03 libuavcan_dsdlc) add_library(uavcan_optim SHARED ${LIBUAVCAN_CXX_FILES}) set_target_properties(uavcan_optim PROPERTIES COMPILE_FLAGS ${optim_flags}) - add_dependencies(uavcan_optim dsdlc) + add_dependencies(uavcan_optim libuavcan_dsdlc) # GTest executables find_package(GTest REQUIRED) diff --git a/libuavcan_drivers/linux/CMakeLists.txt b/libuavcan_drivers/linux/CMakeLists.txt new file mode 100644 index 0000000000..fe7c6c07b5 --- /dev/null +++ b/libuavcan_drivers/linux/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (C) 2014 Pavel Kirienko +# + +cmake_minimum_required(VERSION 2.8) + +project(libuavcan_linux) + +# +# Library (header only) +# +install(DIRECTORY include/uavcan_linux DESTINATION include) + +# +# Test/demo executables +# +find_library(UAVCAN_LIB uavcan REQUIRED) +include_directories(include) +set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -pedantic -std=c++0x -g3 -O1") # GCC or Clang + +add_executable(log_subscriber test/log_subscriber.cpp) +target_link_libraries(log_subscriber ${UAVCAN_LIB}) diff --git a/libuavcan_drivers/linux/cppcheck.sh b/libuavcan_drivers/linux/cppcheck.sh new file mode 100755 index 0000000000..87d6e82739 --- /dev/null +++ b/libuavcan_drivers/linux/cppcheck.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +num_cores=$(grep -c ^processor /proc/cpuinfo) +if [ -z "$num_cores" ]; then + echo "num_cores=? WTF?" + num_cores=4 +fi + +cppcheck . --error-exitcode=1 --quiet --enable=all --platform=unix64 --std=c99 --std=c++11 \ + --inline-suppr --force --template=gcc -j$num_cores \ + -Iinclude $@ diff --git a/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp b/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp @@ -0,0 +1 @@ + diff --git a/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp b/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp @@ -0,0 +1 @@ + diff --git a/libuavcan_drivers/linux/test/log_subscriber.cpp b/libuavcan_drivers/linux/test/log_subscriber.cpp new file mode 100644 index 0000000000..f004c9fd1d --- /dev/null +++ b/libuavcan_drivers/linux/test/log_subscriber.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2014 Pavel Kirienko + */ + +#include +#include +#include +#include + +int main() +{ + std::cout << "Hello owl." << std::endl; + return 0; +}