Merge pull request #151 from gocarlos/feat--add-cmake-support

build: add cmake support
This commit is contained in:
Stefan Wahren
2020-04-24 20:18:09 +02:00
committed by GitHub
25 changed files with 551 additions and 411 deletions

5
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
add_executable(mbus_parse ${CMAKE_CURRENT_LIST_DIR}/mbus_parse.c)
target_link_libraries(mbus_parse PRIVATE libmbus::libmbus)
add_executable(mbus_parse_hex ${CMAKE_CURRENT_LIST_DIR}/mbus_parse_hex.c)
target_link_libraries(mbus_parse_hex PRIVATE libmbus::libmbus)

View File

@ -1,25 +0,0 @@
# ------------------------------------------------------------------------------
# Copyright (C) 2010, Raditex AB
# All rights reserved.
#
# rSCADA
# http://www.rSCADA.se
# info@rscada.se
#
# ------------------------------------------------------------------------------
PACKAGE = @PACKAGE@
VERSION = @VERSION@
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/mbus
noinst_HEADERS =
noinst_PROGRAMS = mbus_parse mbus_parse_hex
mbus_parse_LDFLAGS = -L$(top_builddir)/mbus
mbus_parse_LDADD = -lmbus -lm
mbus_parse_SOURCES = mbus_parse.c
mbus_parse_hex_LDFLAGS = -L$(top_builddir)/mbus
mbus_parse_hex_LDADD = -lmbus -lm
mbus_parse_hex_SOURCES = mbus_parse_hex.c

View File

@ -12,23 +12,34 @@
#
#------------------------------------------------------------------------------
# Check if mbus_parse_hex exists
if [ ! -x ./mbus_parse_hex ]; then
echo "mbus_parse_hex not found"
exit 3
fi
# Check commandline parameter
if [ $# -ne 1 ]; then
echo "usage: $0 directory"
echo "usage: $0 path_to_directory_with_xml_files"
echo "or"
echo "usage: $0 path_to_directory_with_xml_files path_to_mbus_parse_hex_with_filename"
exit 3
fi
directory="$1"
# Check directory
# # Check directory
if [ ! -d "$directory" ]; then
echo "usage: $0 directory"
echo "$directory not found"
exit 3
fi
# Default location is this one
mbus_parse_hex="build/bin/mbus_parse_hex"
# though can be overriten
if [ $# -eq 2 ]; then
mbus_parse_hex="$2"
fi
# Check if mbus_parse_hex exists
if [ ! -x $mbus_parse_hex ]; then
echo "mbus_parse_hex not found"
echo "path to mbus_parse_hex: $mbus_parse_hex"
exit 3
fi
@ -40,7 +51,7 @@ for hexfile in "$directory"/*.hex; do
filename=`basename $hexfile .hex`
# Parse hex file and write XML in file
./mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new"
$mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new"
result=$?
# Check parsing result
@ -74,4 +85,3 @@ for hexfile in "$directory"/*.hex; do
esac
done