Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
Signed-off-by: Adriaan Nieß <mail@adriaan-niess.com>
  • Loading branch information
adriaan-niess committed Sep 8, 2024
1 parent fad6612 commit 961ff15
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ cmake_minimum_required(VERSION 3.20)

project(Open1722 VERSION 0.1)

option(BUILD_TESTS "Build tests" ON)
option(BUILD_EXAMPLES "Build tests" ON)
option(OPEN1722_BUILD_TESTS "Build tests" OFF)
option(OPEN1722_BUILD_EXAMPLES "Build tests" OFF)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)

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

add_library(open1722 SHARED
set(SOURCES
"src/avtp/CommonHeader.c"
"src/avtp/Crf.c"
"src/avtp/Rvf.c"
Expand All @@ -32,7 +33,15 @@ add_library(open1722 SHARED
"src/avtp/cvf/Cvf.c"
"src/avtp/cvf/H264.c"
"src/avtp/cvf/Jpeg2000.c"
"src/avtp/cvf/Mjpeg.c")
"src/avtp/cvf/Mjpeg.c"
)

if(BUILD_SHARED_LIBS)
add_library(open1722 SHARED ${SOURCES})
else()
add_library(open1722 STATIC ${SOURCES})
endif()

set_target_properties(open1722 PROPERTIES VERSION ${PROJECT_VERSION})

target_include_directories(open1722 PRIVATE
Expand All @@ -41,7 +50,7 @@ target_include_directories(open1722 PRIVATE

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

if (BUILD_EXAMPLES)
if (OPEN1722_BUILD_EXAMPLES)
# Common library accross all examples
add_library(open1722examples STATIC "examples/common/common.c")
target_include_directories(open1722examples PRIVATE "examples" "include")
Expand Down Expand Up @@ -99,7 +108,7 @@ endif()

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

if (BUILD_TESTS)
if (OPEN1722_BUILD_TESTS)
enable_testing()

# find_package(cmocka 1.1.0 REQUIRED)
Expand All @@ -125,7 +134,7 @@ endif()
install(TARGETS open1722 EXPORT Open1722Targets DESTINATION lib)
install(DIRECTORY "include/" DESTINATION include)

if (BUILD_EXAMPLES)
if (OPEN1722_BUILD_EXAMPLES)
install(TARGETS
aaf-listener
aaf-talker
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ Before building Open1722 make sure you have installed the following software :

Alternatively, you can use VS Code to run the provided dev container which takes care of the dependencies.

The first step to build Open1722 is to generate the Makefile and build the project.
The first step to build Open1722 is to generate the Makefile and build the project (including example applications and tests).
```
$ mkdir build
$ cd buid
$ cmake ..
$ cmake -DOPEN1722_BUILD_TESTS=ON -DOPEN1722_BUILD_EXAMPLES=ON ..
$ make
```

On default, the example applications and tests are build. It's also possible to disable building examples or tests as shown below. This can be useful to cross-compile Open1722 for microcontrollers.
To build a static library you need to pass the following parameter to CMake
```
$ cmake -DBUILD_TESTS=off -DBUILD_EXAMPLES=off
$ cmake -DBUILD_SHARED_LIBS=OFF
```

The build can be cleaned using the following command:
Expand Down
2 changes: 1 addition & 1 deletion build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ set -ev
rm -rf build
mkdir build
cd build
cmake ..
cmake -DOPEN1722_BUILD_TESTS=ON -DOPEN1722_BUILD_EXAMPLES=ON ..
make -j`nproc`

0 comments on commit 961ff15

Please sign in to comment.