Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added difipack #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions difipack-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.12)
project(difipack
VERSION 0.0.1
DESCRIPTION "C++ implementation of DIFI packet objects"
LANGUAGES CXX
)

enable_testing()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options(-fPIC)

configure_file(
${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
@ONLY)

add_custom_target(uninstall
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)

add_subdirectory(include/difipack)
add_subdirectory(lib)
add_subdirectory(examples)
add_subdirectory(test)

option(BUILD_WITH_DOCS "Generate Docs" OFF)
if(BUILD_WITH_DOCS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/docs)
endif()

install(
TARGETS difipack
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
64 changes: 64 additions & 0 deletions difipack-cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# DIFI Packet C++ Library

## Prerequisites

UHD, gcc/g++, CMake, Boost unit testing framework, and some build system compatible with Cmake

We recommend building UHD from source, however you can download from some package managers.

### Linux (Ubuntu/Debian)

``` bash
sudo apt install gcc cmake make libboost-test-dev
```

## Installing

Configure/generate the build files:

``` bash
# chdr_difi/difipack
mkdir build
cd build
cmake ../
```

Make and install the library

``` bash
make
sudo make install
sudo ldconfig
```

## Uninstalling

The package can be uninstalled by running the following from the build directory created during installation.

``` bash
make uninstall
```

## Running the tests

After building the library, the tests can be run with `make test`. You need boost's unit test framework.

## Building the Docs

Before building the docs, you need to install Doxygen and Graphviz (e.g., `sudo apt install doxygen graphviz`).

Run CMake with the option `-DBUILD_WITH_DOCS=ON`, and then use `make docs` to generate the docs.

``` bash
# chdr_difi/difipack
mkdir build
cd build
cmake -DBUILD_WITH_DOCS=ON ../
make docs
```

The index file can be found at `build/docs/html/index.html`.

## Built With

Ubuntu, VSCode (and C++ Extensions)
32 changes: 32 additions & 0 deletions difipack-cpp/cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F

IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF(EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF(NOT "${rm_retval}" STREQUAL 0)
ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF(NOT "${rm_retval}" STREQUAL 0)
ELSE(EXISTS "$ENV{DESTDIR}${file}")
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH(file)
26 changes: 26 additions & 0 deletions difipack-cpp/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
find_package(Doxygen)
if(DOXYGEN_FOUND)
# Set Doxygen input and output files.
set(DOXYGEN_INPUT_DIRS ${CMAKE_SOURCE_DIR}/include)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

# Generate DoxyFile from the input file.
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)

# Create Output directory.
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})

# Command for generating doc from Doxygen config file.
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating Doxygen documentation"
VERBATIM)
# Create CMake Target for generating doc.
add_custom_target(docs ALL DEPENDS ${DOXYGEN_INDEX_FILE})
else()
message(STATUS "Doxygen not found: skipping docs")
endif()
Loading