Skip to content

Commit

Permalink
Migrate to CMake
Browse files Browse the repository at this point in the history
Signed-off-by: Adriaan Niess <[email protected]>
  • Loading branch information
adriaan-niess committed Jul 17, 2024
1 parent e930e59 commit b770bd4
Show file tree
Hide file tree
Showing 41 changed files with 261 additions and 3,862 deletions.
21 changes: 19 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
build
# Generated directories
/build
/bin
/lib
/release

# CMake
/CMakeFiles
/CMakeCache.txt
/CTestTestfile.cmake
/cmake_install.cmake
/Makefile
/Testing
/CPackConfig.cmake
/CPackSourceConfig.cmake
/install_manifest.txt
/_CPack_Packages

*~
.vscode
.vscode
151 changes: 151 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
cmake_minimum_required(VERSION 3.20)

project(open1722 VERSION 0.1)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")

#### Libraries ################################################################

# PDU parsing library
add_library(open1722pdu SHARED
"src/avtp/CommonHeader.c"
"src/avtp/Crf.c"
"src/avtp/Rvf.c"
"src/avtp/Udp.c"
"src/avtp/Utils.c"
"src/avtp/aaf/CommonStream.c"
"src/avtp/aaf/PcmStream.c"
"src/avtp/acf/Can.c"
"src/avtp/acf/CanBrief.c"
"src/avtp/acf/Common.c"
"src/avtp/acf/Ntscf.c"
"src/avtp/acf/Sensor.c"
"src/avtp/acf/SensorBrief.c"
"src/avtp/acf/Tscf.c"
"src/avtp/cvf/Cvf.c"
"src/avtp/cvf/H264.c"
"src/avtp/cvf/Jpeg2000.c"
"src/avtp/cvf/Mjpeg.c")
target_include_directories(open1722pdu PRIVATE "${PROJECT_BINARY_DIR}/include")

# link_directories(lib)

#### Examples #################################################################

# Common library accross all examples
add_library(open1722examples STATIC "examples/common/common.c")
target_include_directories(open1722examples PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")

# AAF listener app
add_executable(aaf-listener "examples/aaf/aaf-listener.c")
target_include_directories(aaf-listener PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(aaf-listener open1722pdu open1722examples)

# AAF talker app
add_executable(aaf-talker "examples/aaf/aaf-talker.c")
target_include_directories(aaf-talker PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(aaf-talker open1722pdu open1722examples)

# CAN talker app
add_executable(acf-can-talker "examples/acf-can/acf-can-talker.c")
target_include_directories(acf-can-talker PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(acf-can-talker open1722pdu open1722examples)

# CAN listener app
add_executable(acf-can-listener "examples/acf-can/acf-can-listener.c")
target_include_directories(acf-can-listener PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(acf-can-listener open1722pdu open1722examples)

# CRF talker app
add_executable(crf-talker "examples/crf/crf-talker.c")
target_include_directories(crf-talker PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(crf-talker open1722pdu open1722examples m)

# CRF listener app
add_executable(crf-listener "examples/crf/crf-listener.c")
target_include_directories(crf-listener PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(crf-listener open1722pdu open1722examples m)

# CVF talker app
add_executable(cvf-talker "examples/cvf/cvf-talker.c")
target_include_directories(cvf-talker PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(cvf-talker open1722pdu open1722examples)

# CVF listener app
add_executable(cvf-listener "examples/cvf/cvf-listener.c")
target_include_directories(cvf-listener PRIVATE
"${PROJECT_BINARY_DIR}/examples"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(cvf-listener open1722pdu open1722examples)

#### Tests ####################################################################

enable_testing()

find_package(cmocka 1.1.0 REQUIRED)

list(APPEND TEST_TARGETS test-aaf)
list(APPEND TEST_TARGETS test-avtp)
list(APPEND TEST_TARGETS test-can)
list(APPEND TEST_TARGETS test-crf)
list(APPEND TEST_TARGETS test-cvf)
list(APPEND TEST_TARGETS test-rvf)
# list(APPEND TEST_TARGETS test-stream)

foreach(TEST_TARGET IN LISTS TEST_TARGETS)
add_executable(${TEST_TARGET} "unit/${TEST_TARGET}.c")
target_include_directories(${TEST_TARGET} PRIVATE "${PROJECT_BINARY_DIR}/include")
target_link_libraries(${TEST_TARGET} open1722pdu cmocka m)
add_test(NAME ${TEST_TARGET} COMMAND "${PROJECT_BINARY_DIR}/bin/${TEST_TARGET}")
endforeach()

#### Install ##################################################################

install(TARGETS open1722pdu DESTINATION lib)
install(TARGETS
aaf-listener
aaf-talker
acf-can-listener
acf-can-talker
crf-listener
crf-talker
cvf-listener
cvf-talker
DESTINATION bin)
install(DIRECTORY include/ DESTINATION include)

#### Packaging ################################################################

include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${open1722_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${open1722_VERSION_MINOR}")
set(CPACK_PACKAGE_DIRECTORY "${PROJECT_BINARY_DIR}/release")
set(CPACK_GENERATOR "TGZ" "DEB")
set(CPACK_SOURCE_GENERATOR "TGZ" "DEB")

# Debian package
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Adriaan Niess [Robert Bosch GmbH]")

include(CPack)
14 changes: 1 addition & 13 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
#!/bin/bash
set -ev

mkdir -p build
meson . build -Db_coverage=true
meson compile -C build/ \
examples/aaf/aaf-listener \
examples/aaf/aaf-talker \
examples/acf-can/acf-can-listener \
examples/acf-can/acf-can-talker \
examples/crf/crf-talker \
examples/crf/crf-listener \
examples/cvf/cvf-talker \
examples/cvf/cvf-listener \
examples/ieciidc/ieciidc-talker \
examples/ieciidc/ieciidc-listener
cmake . && make
3 changes: 1 addition & 2 deletions examples/aaf/aaf-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@
#include <unistd.h>
#include <inttypes.h>

#include "avtp.h"
#include "avtp/aaf/PcmStream.h"
#include "common.h"
#include "common/common.h"
#include "avtp/CommonHeader.h"

#define STREAM_ID 0xAABBCCDDEEFF0001
Expand Down
3 changes: 1 addition & 2 deletions examples/aaf/aaf-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@
#include <string.h>
#include <unistd.h>

#include "avtp.h"
#include "avtp/aaf/PcmStream.h"
#include "common.h"
#include "common/common.h"
#include "avtp/CommonHeader.h"

#define STREAM_ID 0xAABBCCDDEEFF0001
Expand Down
15 changes: 0 additions & 15 deletions examples/aaf/meson.build

This file was deleted.

2 changes: 1 addition & 1 deletion examples/acf-can/acf-can-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <linux/can/raw.h>
#include <sys/ioctl.h>

#include "common.h"
#include "common/common.h"
#include "avtp/Udp.h"
#include "avtp/acf/Ntscf.h"
#include "avtp/acf/Tscf.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/acf-can/acf-can-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <stdio.h>
#include <time.h>

#include "common.h"
#include "common/common.h"
#include "avtp/Udp.h"
#include "avtp/acf/Ntscf.h"
#include "avtp/acf/Tscf.h"
Expand Down
15 changes: 0 additions & 15 deletions examples/acf-can/meson.build

This file was deleted.

2 changes: 1 addition & 1 deletion examples/common.c → examples/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <time.h>
#include <unistd.h>

#include "common.h"
#include "common/common.h"

#define NSEC_PER_SEC 1000000000ULL
#define NSEC_PER_MSEC 1000000ULL
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions examples/crf/crf-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@
#include <math.h>
#include <inttypes.h>

#include "avtp.h"
#include "avtp/Crf.h"
#include "avtp/aaf/PcmStream.h"
#include "common.h"
#include "common/common.h"
#include "avtp/CommonHeader.h"

#define AAF_STREAM_ID 0xAABBCCDDEEFF0001
Expand Down
3 changes: 1 addition & 2 deletions examples/crf/crf-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@
#include <unistd.h>
#include <math.h>

#include "avtp.h"
#include "avtp/Crf.h"
#include "common.h"
#include "common/common.h"
#include "avtp/CommonHeader.h"

#define STREAM_ID 0xAABBCCDDEEFF0002
Expand Down
18 changes: 0 additions & 18 deletions examples/crf/meson.build

This file was deleted.

3 changes: 1 addition & 2 deletions examples/cvf/cvf-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@
#include <unistd.h>
#include <inttypes.h>

#include "avtp.h"
#include "avtp/cvf/Cvf.h"
#include "avtp/cvf/H264.h"
#include "avtp/CommonHeader.h"
#include "common.h"
#include "common/common.h"

#define STREAM_ID 0xAABBCCDDEEFF0001
#define DATA_LEN 1400
Expand Down
3 changes: 1 addition & 2 deletions examples/cvf/cvf-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@
#include <string.h>
#include <unistd.h>

#include "avtp.h"
#include "avtp/cvf/Cvf.h"
#include "avtp/cvf/H264.h"
#include "common.h"
#include "common/common.h"
#include "avtp/CommonHeader.h"

#define STREAM_ID 0xAABBCCDDEEFF0001
Expand Down
15 changes: 0 additions & 15 deletions examples/cvf/meson.build

This file was deleted.

34 changes: 0 additions & 34 deletions examples/ieciidc/README.md

This file was deleted.

Loading

0 comments on commit b770bd4

Please sign in to comment.