-
Notifications
You must be signed in to change notification settings - Fork 4.9k
realsense2-all #12310
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
realsense2-all #12310
Changes from all commits
9b53a09
574d416
31c93b8
7edb9f2
64cba7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 ) | ||
|
|
||
| # | ||
| # 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" ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we wish to debug?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NVM, test only is fine There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| 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() | ||
|
|
||
| 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; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
|
|
||
Nir-Az marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 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 ) | ||
|
|
||
|
|
||
| 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 | ||
Nir-Az marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| # 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() | ||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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-allmakefile works fine in U18. But this client is made for U20+. That's fine.