Skip to content

Commit 7979fd4

Browse files
authored
PR #12310 from Eran: realsense2-all
2 parents aee7ed6 + 64cba7b commit 7979fd4

File tree

11 files changed

+327
-76
lines changed

11 files changed

+327
-76
lines changed

.github/workflows/buildsCI.yaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
138138
shell: bash
139139
run: |
140-
LRS_SRC_DIR=$(pwd)
140+
LRS_SRC_DIR=$(pwd)
141141
cd ${{env.WIN_BUILD_DIR}}
142142
cmake ${LRS_SRC_DIR} -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=true -DUNIT_TESTS_ARGS="--not-live --context=windows" -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=false -DPYTHON_EXECUTABLE=${{env.PYTHON_PATH}} -DBUILD_PYTHON_BINDINGS=true
143143
@@ -154,6 +154,15 @@ jobs:
154154
run: |
155155
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "windows" ${{env.WIN_BUILD_DIR}}/Release
156156
157+
- name: Client for realsense2-all
158+
shell: bash
159+
run: |
160+
mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client
161+
cd ${{env.WIN_BUILD_DIR}}/rs-all-client
162+
cmake $GITHUB_WORKSPACE/.github/workflows/rs-all-client -G "Visual Studio 16 2019"
163+
cmake --build . --config Release -- -m
164+
./Release/rs-all-client
165+
157166
158167
#--------------------------------------------------------------------------------
159168
Win_SH_Py_DDS_CI: # Windows, Shared, Python, Tools, DDS, libCI without executables
@@ -382,7 +391,16 @@ jobs:
382391
run: |
383392
cd build
384393
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) -DFORCE_RSUSB_BACKEND=true
385-
cmake --build . -- -j4
394+
cmake --build . -- -j4
395+
396+
- name: Client for realsense2-all
397+
shell: bash
398+
run: |
399+
mkdir build/rs-all-client
400+
cd build/rs-all-client
401+
cmake ../../.github/workflows/rs-all-client -DBUILD_WITH_DDS=ON -DFORCE_RSUSB_BACKEND=ON
402+
cmake --build . -- -j4
403+
./rs-all-client
386404
387405
- name: LibCI
388406
# Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run
@@ -394,12 +412,12 @@ jobs:
394412

395413
#--------------------------------------------------------------------------------
396414
U22_SH_RSUSB_LiveTest: # Ubuntu 2022, Shared, Legacy live-tests
397-
runs-on: ubuntu-22.04
415+
runs-on: ubuntu-22.04
398416
timeout-minutes: 60
399417
env:
400418
LRS_BUILD_NODEJS: true
401419
steps:
402-
- uses: actions/checkout@v3
420+
- uses: actions/checkout@v3
403421

404422
- name: Check_API
405423
shell: bash
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# License: Apache 2.0. See LICENSE file in root directory.
2+
# Copyright(c) 2023 Intel Corporation. All Rights Reserved.
3+
cmake_minimum_required( VERSION 3.15 )
4+
5+
#
6+
# This tests whether we can link with realsense2-all and not have any missing external symbols.
7+
# Without realsense2-all, we'd need to link with:
8+
# realsense2 realsense-file rsutils
9+
# Or, if DDS was enabled:
10+
# realsense2 realsense-file rsutils fastcdr fastrtps foonathan_memory realdds
11+
# And the list gets longer if we add libraries.
12+
#
13+
# On Windows, no additional special libraries are needed.
14+
# On Linux, we have other dependencies:
15+
# libusb udev
16+
# These are not part of realsense2-all, even though we depend on them!
17+
#
18+
19+
project( rs-all-client )
20+
21+
option( BUILD_SHARED_LIBS "Build using shared libraries" OFF )
22+
23+
if( WIN32 )
24+
# Take away the other configurations because they'd require we picked another link
25+
# directory and target... keep it simple...
26+
set( CMAKE_CONFIGURATION_TYPES "Release" )
27+
endif()
28+
29+
add_executable( ${PROJECT_NAME} main.cpp )
30+
set_target_properties( ${PROJECT_NAME} PROPERTIES
31+
CXX_STANDARD 14
32+
MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug> # New in version 3.15; ignored in Linux
33+
)
34+
35+
target_include_directories( ${PROJECT_NAME} PRIVATE
36+
../../../include
37+
../../../third-party/rsutils/include
38+
)
39+
target_link_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/../Release )
40+
41+
target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all )
42+
43+
if( NOT WIN32 )
44+
find_library( LIBUSB NAMES usb-1.0 )
45+
target_link_libraries( ${PROJECT_NAME} PRIVATE pthread ${LIBUSB} )
46+
if( NOT FORCE_RSUSB_BACKEND )
47+
target_link_libraries( ${PROJECT_NAME} PRIVATE udev )
48+
endif()
49+
if( BUILD_WITH_DDS )
50+
target_link_libraries( ${PROJECT_NAME} PRIVATE ssl crypto rt )
51+
endif()
52+
endif()
53+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// License: Apache 2.0. See LICENSE file in root directory.
2+
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
3+
4+
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
5+
6+
#include <rsutils/time/timer.h>
7+
#include <iostream> // for cout
8+
#include <chrono>
9+
#include <thread>
10+
11+
int main(int argc, char * argv[]) try
12+
{
13+
rs2::log_to_console( RS2_LOG_SEVERITY_DEBUG );
14+
15+
rs2::context context;
16+
auto devices = context.query_devices();
17+
if( devices.size() )
18+
{
19+
// This can run under GHA, too -- so we don't always have devices
20+
// Run for just a little bit, count the frames
21+
size_t n_frames = 0;
22+
{
23+
rs2::pipeline p( context );
24+
auto profile = p.start();
25+
auto device = profile.get_device();
26+
std::cout << "Streaming on " << device.get_info( RS2_CAMERA_INFO_NAME ) << std::endl;
27+
28+
rsutils::time::timer timer( std::chrono::seconds( 3 ) );
29+
while( ! timer.has_expired() )
30+
{
31+
// Block program until frames arrive
32+
rs2::frameset frames = p.wait_for_frames();
33+
++n_frames;
34+
}
35+
}
36+
37+
std::cout << "Got " << n_frames << " frames" << std::endl;
38+
}
39+
else
40+
{
41+
// Allow enough time for DDS enumeration
42+
std::this_thread::sleep_for( std::chrono::seconds( 3 ) );
43+
}
44+
45+
return EXIT_SUCCESS;
46+
}
47+
catch (const rs2::error & e)
48+
{
49+
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
50+
return EXIT_FAILURE;
51+
}
52+
catch (const std::exception& e)
53+
{
54+
std::cerr << e.what() << std::endl;
55+
return EXIT_FAILURE;
56+
}

CMake/Findfoonathan_memory.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# This is a dummy file, just so CMake does not complain:
3+
4+
# CMake Error at build/third-party/fastdds/CMakeLists.txt:239 (find_package):
5+
# By not providing "Findfoonathan_memory.cmake" in CMAKE_MODULE_PATH this
6+
# project has asked CMake to find a package configuration file provided by
7+
# "foonathan_memory", but CMake did not find one.
8+
#
9+
# Could not find a package configuration file provided by "foonathan_memory"
10+
# with any of the following names:
11+
#
12+
# foonathan_memoryConfig.cmake
13+
# foonathan_memory-config.cmake
14+
#
15+
# Add the installation prefix of "foonathan_memory" to CMAKE_PREFIX_PATH or
16+
# set "foonathan_memory_DIR" to a directory containing one of the above
17+
# files. If "foonathan_memory" provides a separate development package or
18+
# SDK, be sure it has been installed.
19+
20+
# FastDDS requires foonathan_memory and will not find it if we do not provide this
21+
# file.
22+
#
23+
# Since all the variables should already be set by external_foonathan_memory.cmake,
24+
# we don't really do anything.
25+
26+
# This may not be the proper way to do this. But it works...
27+
28+
29+
#message( "In Findfoonathan_memory.cmake" )
30+
31+
32+
#find_package( PkgConfig )
33+
#pkg_check_modules( foonathan_memory QUIET foonathan_memory )
34+
35+

CMake/external_fastdds.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ function(get_fastdds)
4747
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FASTDDS)
4848

4949
# place FastDDS project with other 3rd-party projects
50-
set_target_properties(fastcdr fastrtps PROPERTIES
50+
set_target_properties(fastcdr fastrtps foonathan_memory PROPERTIES
5151
FOLDER "3rd Party/fastdds")
5252

5353
list(POP_BACK CMAKE_MESSAGE_INDENT) # Unindent outputs
5454

5555
add_library(dds INTERFACE)
56-
target_link_libraries(dds INTERFACE fastcdr fastrtps)
56+
target_link_libraries( dds INTERFACE fastcdr fastrtps )
5757

5858
add_definitions(-DBUILD_WITH_DDS)
5959

Lines changed: 31 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,44 @@
11
cmake_minimum_required(VERSION 3.11)
22
include(FetchContent)
33

4-
# Mark new options from FetchContent as advanced options
5-
mark_as_advanced(FETCHCONTENT_QUIET)
6-
mark_as_advanced(FETCHCONTENT_BASE_DIR)
7-
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
8-
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
4+
# We use a function to enforce a scoped variables creation only for FastDDS build (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
5+
function(get_foonathan_memory)
96

10-
message(CHECK_START "Fetching & Installing foonathan_memory...")
11-
list(APPEND CMAKE_MESSAGE_INDENT " ")
7+
# Mark new options from FetchContent as advanced options
8+
mark_as_advanced(FETCHCONTENT_QUIET)
9+
mark_as_advanced(FETCHCONTENT_BASE_DIR)
10+
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
11+
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
1212

13-
FetchContent_Declare(
14-
foonathan_memory
15-
GIT_REPOSITORY https://github.com/foonathan/memory.git
16-
GIT_TAG "v0.7-2"
17-
GIT_SHALLOW ON # No history needed
18-
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/foonathan_memory
19-
)
13+
message(CHECK_START "Fetching foonathan_memory...")
14+
list(APPEND CMAKE_MESSAGE_INDENT " ")
2015

21-
# Remove unrequired targets
22-
set(FOONATHAN_MEMORY_BUILD_VARS -DBUILD_SHARED_LIBS=OFF # explicit set static lib
23-
-DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF
24-
-DFOONATHAN_MEMORY_BUILD_TESTS=OFF
25-
-DFOONATHAN_MEMORY_BUILD_TOOLS=ON) # this tool is needed during configure time only, FastDDS recommend turning it ON.
26-
27-
# Align STATIC CRT definitions with LRS
28-
if(BUILD_WITH_STATIC_CRT)
29-
set(FOONATHAN_MEMORY_BUILD_VARS ${FOONATHAN_MEMORY_BUILD_VARS}
30-
-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW
31-
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>)
32-
endif()
33-
16+
FetchContent_Declare(
17+
foonathan_memory
18+
GIT_REPOSITORY https://github.com/foonathan/memory.git
19+
GIT_TAG "v0.7-3"
20+
GIT_SHALLOW ON # No history needed
21+
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/foonathan_memory
22+
)
3423

35-
# Since `FastDDS` require foonathan_memory package installed during configure time,
36-
# We download it build it and install it both in Release & Debug configuration since we need both available.
37-
# We use `FetchContent_Populate` and not `FetchContent_MakeAvailable` for that reason, we want to manually configure and build it.
38-
FetchContent_GetProperties(foonathan_memory)
39-
if(NOT foonathan_memory_POPULATED)
40-
FetchContent_Populate(foonathan_memory)
41-
endif()
24+
# Always a static library
25+
set( BUILD_SHARED_LIBS OFF )
4226

43-
# Mark new options from FetchContent as advanced options
44-
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FOONATHAN_MEMORY)
45-
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FOONATHAN_MEMORY)
27+
# Set foonathan_memory variables
28+
# These are exposed options; not internal
29+
set( FOONATHAN_MEMORY_BUILD_EXAMPLES OFF )
30+
set( FOONATHAN_MEMORY_BUILD_TESTS OFF )
31+
set( FOONATHAN_MEMORY_BUILD_TOOLS OFF )
4632

33+
FetchContent_MakeAvailable( foonathan_memory )
4734

48-
# Configure stage
49-
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/fastdds/fastdds_install
50-
${FOONATHAN_MEMORY_BUILD_VARS}
51-
.
52-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
53-
OUTPUT_QUIET
54-
RESULT_VARIABLE configure_ret
55-
)
35+
# Mark new options from FetchContent as advanced options
36+
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FOONATHAN_MEMORY)
37+
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FOONATHAN_MEMORY)
5638

57-
# Build and install Debug version
58-
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug --target install
59-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
60-
OUTPUT_QUIET
61-
RESULT_VARIABLE debug_build_ret
62-
)
39+
list(POP_BACK CMAKE_MESSAGE_INDENT)
40+
message(CHECK_PASS "Done")
6341

64-
# Build and install RelWithDeb version
65-
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config RelWithDebInfo --target install
66-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
67-
OUTPUT_QUIET
68-
RESULT_VARIABLE rel_with_deb_info_build_ret
69-
)
42+
endfunction()
7043

71-
# Build and install Release version
72-
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release --target install
73-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
74-
OUTPUT_QUIET
75-
RESULT_VARIABLE release_build_ret
76-
)
77-
78-
if(configure_ret OR debug_build_ret OR release_build_ret OR rel_with_deb_info_build_ret)
79-
message( FATAL_ERROR "Failed to build foonathan_memory")
80-
endif()
81-
82-
list(POP_BACK CMAKE_MESSAGE_INDENT)
83-
message(CHECK_PASS "Done")
44+
get_foonathan_memory()

CMake/lrs_options.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ else()
4747
endif()
4848
option(BUILD_PC_STITCHING "Build pointcloud-stitching example" OFF)
4949
option(BUILD_WITH_DDS "Access camera devices through DDS topics (requires CMake 3.16.3)" OFF)
50+
option(BUILD_RS2_ALL "Build realsense2-all static bundle containing all realsense libraries (with BUILD_SHARED_LIBS=OFF)" ON)
5051

CMake/unix_config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ macro(os_set_flags)
1111
endif()
1212
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
1313
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
14+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
1415

1516
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1617
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -D_DEFAULT_SOURCE")

CMake/windows_config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ macro(os_set_flags)
99
# Note: this puts the outputs under <binary>/<build-type>
1010
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1111
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
12+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1213

1314
if(BUILD_WITH_OPENMP)
1415
find_package(OpenMP REQUIRED)

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,6 @@ endif()
119119

120120
include(CMake/embedd_udev_rules.cmake)
121121

122+
if( BUILD_RS2_ALL )
123+
include( src/realsense2-all.cmake )
124+
endif()

0 commit comments

Comments
 (0)