Skip to content
Merged
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
26 changes: 22 additions & 4 deletions .github/workflows/buildsCI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
shell: bash
run: |
LRS_SRC_DIR=$(pwd)
LRS_SRC_DIR=$(pwd)
cd ${{env.WIN_BUILD_DIR}}
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

Expand All @@ -154,6 +154,15 @@ jobs:
run: |
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "windows" ${{env.WIN_BUILD_DIR}}/Release

- name: Client for realsense2-all
shell: bash
run: |
mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client
cd ${{env.WIN_BUILD_DIR}}/rs-all-client
cmake $GITHUB_WORKSPACE/.github/workflows/rs-all-client -G "Visual Studio 16 2019"
cmake --build . --config Release -- -m
./Release/rs-all-client


#--------------------------------------------------------------------------------
Win_SH_Py_DDS_CI: # Windows, Shared, Python, Tools, DDS, libCI without executables
Expand Down Expand Up @@ -382,7 +391,16 @@ jobs:
run: |
cd build
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
cmake --build . -- -j4
cmake --build . -- -j4

- name: Client for realsense2-all
shell: bash
run: |
mkdir build/rs-all-client
cd build/rs-all-client
cmake ../../.github/workflows/rs-all-client -DBUILD_WITH_DDS=ON -DFORCE_RSUSB_BACKEND=ON
cmake --build . -- -j4
./rs-all-client

- name: LibCI
# Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run
Expand All @@ -394,12 +412,12 @@ jobs:

#--------------------------------------------------------------------------------
U22_SH_RSUSB_LiveTest: # Ubuntu 2022, Shared, Legacy live-tests
runs-on: ubuntu-22.04
runs-on: ubuntu-22.04
timeout-minutes: 60
env:
LRS_BUILD_NODEJS: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Check_API
shell: bash
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/rs-all-client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2023 Intel Corporation. All Rights Reserved.
cmake_minimum_required( VERSION 3.15 )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bump our minimal CMake version.
For windows it's less painfull but I believe we can condition it with the version.
<3.15 dont build it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's just the test, forget it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right... wouldn't the static analysis catch this?? Weird.
I'll try it on U18.

Copy link
Contributor Author

@maloel maloel Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh!
Duh...
This is the GHA client!
It doesn't run on U18...
realsense2-all makefile works fine in U18. But this client is made for U20+. That's fine.


#
# This tests whether we can link with realsense2-all and not have any missing external symbols.
# Without realsense2-all, we'd need to link with:
# realsense2 realsense-file rsutils
# Or, if DDS was enabled:
# realsense2 realsense-file rsutils fastcdr fastrtps foonathan_memory realdds
# And the list gets longer if we add libraries.
#
# On Windows, no additional special libraries are needed.
# On Linux, we have other dependencies:
# libusb udev
# These are not part of realsense2-all, even though we depend on them!
#

project( rs-all-client )

option( BUILD_SHARED_LIBS "Build using shared libraries" OFF )

if( WIN32 )
# Take away the other configurations because they'd require we picked another link
# directory and target... keep it simple...
set( CMAKE_CONFIGURATION_TYPES "Release" )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we wish to debug??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM, test only is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the unit-test, which only runs in GHA and compiles a specific build.
If you need to debug (unlikely) just remove the line. You'd have to make sure everything else lines up.

endif()

add_executable( ${PROJECT_NAME} main.cpp )
set_target_properties( ${PROJECT_NAME} PROPERTIES
CXX_STANDARD 14
MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug> # New in version 3.15; ignored in Linux
)

target_include_directories( ${PROJECT_NAME} PRIVATE
../../../include
../../../third-party/rsutils/include
)
target_link_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/../Release )

target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all )

if( NOT WIN32 )
find_library( LIBUSB NAMES usb-1.0 )
target_link_libraries( ${PROJECT_NAME} PRIVATE pthread ${LIBUSB} )
if( NOT FORCE_RSUSB_BACKEND )
target_link_libraries( ${PROJECT_NAME} PRIVATE udev )
endif()
if( BUILD_WITH_DDS )
target_link_libraries( ${PROJECT_NAME} PRIVATE ssl crypto rt )
endif()
endif()

56 changes: 56 additions & 0 deletions .github/workflows/rs-all-client/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API

#include <rsutils/time/timer.h>
#include <iostream> // for cout
#include <chrono>
#include <thread>

int main(int argc, char * argv[]) try
{
rs2::log_to_console( RS2_LOG_SEVERITY_DEBUG );

rs2::context context;
auto devices = context.query_devices();
if( devices.size() )
{
// This can run under GHA, too -- so we don't always have devices
// Run for just a little bit, count the frames
size_t n_frames = 0;
{
rs2::pipeline p( context );
auto profile = p.start();
auto device = profile.get_device();
std::cout << "Streaming on " << device.get_info( RS2_CAMERA_INFO_NAME ) << std::endl;

rsutils::time::timer timer( std::chrono::seconds( 3 ) );
while( ! timer.has_expired() )
{
// Block program until frames arrive
rs2::frameset frames = p.wait_for_frames();
++n_frames;
}
}

std::cout << "Got " << n_frames << " frames" << std::endl;
}
else
{
// Allow enough time for DDS enumeration
std::this_thread::sleep_for( std::chrono::seconds( 3 ) );
}

return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
35 changes: 35 additions & 0 deletions CMake/Findfoonathan_memory.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# This is a dummy file, just so CMake does not complain:

# CMake Error at build/third-party/fastdds/CMakeLists.txt:239 (find_package):
# By not providing "Findfoonathan_memory.cmake" in CMAKE_MODULE_PATH this
# project has asked CMake to find a package configuration file provided by
# "foonathan_memory", but CMake did not find one.
#
# Could not find a package configuration file provided by "foonathan_memory"
# with any of the following names:
#
# foonathan_memoryConfig.cmake
# foonathan_memory-config.cmake
#
# Add the installation prefix of "foonathan_memory" to CMAKE_PREFIX_PATH or
# set "foonathan_memory_DIR" to a directory containing one of the above
# files. If "foonathan_memory" provides a separate development package or
# SDK, be sure it has been installed.

# FastDDS requires foonathan_memory and will not find it if we do not provide this
# file.
#
# Since all the variables should already be set by external_foonathan_memory.cmake,
# we don't really do anything.

# This may not be the proper way to do this. But it works...


#message( "In Findfoonathan_memory.cmake" )


#find_package( PkgConfig )
#pkg_check_modules( foonathan_memory QUIET foonathan_memory )


4 changes: 2 additions & 2 deletions CMake/external_fastdds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ function(get_fastdds)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FASTDDS)

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

list(POP_BACK CMAKE_MESSAGE_INDENT) # Unindent outputs

add_library(dds INTERFACE)
target_link_libraries(dds INTERFACE fastcdr fastrtps)
target_link_libraries( dds INTERFACE fastcdr fastrtps )

add_definitions(-DBUILD_WITH_DDS)

Expand Down
101 changes: 31 additions & 70 deletions CMake/external_foonathan_memory.cmake
Original file line number Diff line number Diff line change
@@ -1,83 +1,44 @@
cmake_minimum_required(VERSION 3.11)
include(FetchContent)

# Mark new options from FetchContent as advanced options
mark_as_advanced(FETCHCONTENT_QUIET)
mark_as_advanced(FETCHCONTENT_BASE_DIR)
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
# 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)
function(get_foonathan_memory)

message(CHECK_START "Fetching & Installing foonathan_memory...")
list(APPEND CMAKE_MESSAGE_INDENT " ")
# Mark new options from FetchContent as advanced options
mark_as_advanced(FETCHCONTENT_QUIET)
mark_as_advanced(FETCHCONTENT_BASE_DIR)
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)

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

# Remove unrequired targets
set(FOONATHAN_MEMORY_BUILD_VARS -DBUILD_SHARED_LIBS=OFF # explicit set static lib
-DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF
-DFOONATHAN_MEMORY_BUILD_TESTS=OFF
-DFOONATHAN_MEMORY_BUILD_TOOLS=ON) # this tool is needed during configure time only, FastDDS recommend turning it ON.

# Align STATIC CRT definitions with LRS
if(BUILD_WITH_STATIC_CRT)
set(FOONATHAN_MEMORY_BUILD_VARS ${FOONATHAN_MEMORY_BUILD_VARS}
-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>)
endif()

FetchContent_Declare(
foonathan_memory
GIT_REPOSITORY https://github.com/foonathan/memory.git
GIT_TAG "v0.7-3"
GIT_SHALLOW ON # No history needed
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/foonathan_memory
)

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

# Mark new options from FetchContent as advanced options
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FOONATHAN_MEMORY)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FOONATHAN_MEMORY)
# Set foonathan_memory variables
# These are exposed options; not internal
set( FOONATHAN_MEMORY_BUILD_EXAMPLES OFF )
set( FOONATHAN_MEMORY_BUILD_TESTS OFF )
set( FOONATHAN_MEMORY_BUILD_TOOLS OFF )

FetchContent_MakeAvailable( foonathan_memory )

# Configure stage
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/fastdds/fastdds_install
${FOONATHAN_MEMORY_BUILD_VARS}
.
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE configure_ret
)
# Mark new options from FetchContent as advanced options
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FOONATHAN_MEMORY)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FOONATHAN_MEMORY)

# Build and install Debug version
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE debug_build_ret
)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "Done")

# Build and install RelWithDeb version
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config RelWithDebInfo --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE rel_with_deb_info_build_ret
)
endfunction()

# Build and install Release version
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE release_build_ret
)

if(configure_ret OR debug_build_ret OR release_build_ret OR rel_with_deb_info_build_ret)
message( FATAL_ERROR "Failed to build foonathan_memory")
endif()

list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "Done")
get_foonathan_memory()
1 change: 1 addition & 0 deletions CMake/lrs_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ else()
endif()
option(BUILD_PC_STITCHING "Build pointcloud-stitching example" OFF)
option(BUILD_WITH_DDS "Access camera devices through DDS topics (requires CMake 3.16.3)" OFF)
option(BUILD_RS2_ALL "Build realsense2-all static bundle containing all realsense libraries (with BUILD_SHARED_LIBS=OFF)" ON)

1 change: 1 addition & 0 deletions CMake/unix_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ macro(os_set_flags)
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -D_DEFAULT_SOURCE")
Expand Down
1 change: 1 addition & 0 deletions CMake/windows_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ macro(os_set_flags)
# Note: this puts the outputs under <binary>/<build-type>
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

if(BUILD_WITH_OPENMP)
find_package(OpenMP REQUIRED)
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ endif()

include(CMake/embedd_udev_rules.cmake)

if( BUILD_RS2_ALL )
include( src/realsense2-all.cmake )
endif()
Loading