From a653a93950a3c09cad6b8aeb3e5c7cb297256997 Mon Sep 17 00:00:00 2001 From: Eran Date: Fri, 13 Oct 2023 12:06:23 +0300 Subject: [PATCH] realsense2 PRIVATE rsutils, to avoid .a dependency --- CMake/opengl_config.cmake | 2 +- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 6 +- src/gl/CMakeLists.txt | 6 +- tools/CMakeLists.txt | 2 +- tools/rosbag-inspector/CMakeLists.txt | 93 +++++++++++++-------------- unit-tests/CMakeLists.txt | 2 +- unit-tests/unit-test-config.py | 2 +- wrappers/CMakeLists.txt | 2 +- 9 files changed, 56 insertions(+), 61 deletions(-) diff --git a/CMake/opengl_config.cmake b/CMake/opengl_config.cmake index 8c7e9fcf90..43ec4bac16 100644 --- a/CMake/opengl_config.cmake +++ b/CMake/opengl_config.cmake @@ -4,4 +4,4 @@ if (POLICY CMP0072) endif() find_package(OpenGL REQUIRED) -set(DEPENDENCIES realsense2 glfw ${OPENGL_LIBRARIES}) +list( APPEND DEPENDENCIES glfw ${OPENGL_LIBRARIES} ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9779ff8373..a5b913a73a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ target_include_directories( rsutils $ ) -target_link_libraries( ${LRS_TARGET} PUBLIC rsutils ) +target_link_libraries( ${LRS_TARGET} PRIVATE rsutils ) if(BUILD_WITH_DDS) if (CMAKE_SYSTEM MATCHES "Windows" OR CMAKE_SYSTEM MATCHES "Linux") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8281fb33cf..a790d954b0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,14 +7,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # View the makefile commands during build #set(CMAKE_VERBOSE_MAKEFILE on) +set( DEPENDENCIES realsense2 ) + if(BUILD_GRAPHICAL_EXAMPLES) include(${CMAKE_SOURCE_DIR}/CMake/opengl_config.cmake) else() if(ANDROID_NDK_TOOLCHAIN_INCLUDED) find_library(log-lib log) - set(DEPENDENCIES realsense2 log) - else() - set(DEPENDENCIES realsense2) + list( APPEND DEPENDENCIES log ) endif() endif() diff --git a/src/gl/CMakeLists.txt b/src/gl/CMakeLists.txt index a6cd8e17b7..4aa0201198 100644 --- a/src/gl/CMakeLists.txt +++ b/src/gl/CMakeLists.txt @@ -42,6 +42,7 @@ set(REALSENSE_GL_PUBLIC_HEADERS set(CMAKECONFIG_GL_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${LRS_GL_TARGET}") +set( DEPENDENCIES realsense2 rsutils ) include(${CMAKE_SOURCE_DIR}/CMake/opengl_config.cmake) if (${BUILD_SHARED_LIBS} AND ${BUILD_EASYLOGGINGPP}) @@ -88,10 +89,7 @@ configure_package_config_file(../../CMake/realsense2-glConfig.cmake.in realsense configure_file(../../config/librealsense-gl.pc.in ../../config/realsense2-gl.pc @ONLY) -target_link_libraries( ${PROJECT_NAME} - PRIVATE - ${DEPENDENCIES} - ) +target_link_libraries( ${PROJECT_NAME} PRIVATE ${DEPENDENCIES} ) # CMake prior to 3.13 cannot install targets located in sub-directories. #https://gitlab.kitware.com/cmake/cmake/merge_requests/2152 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index d8ffd766b3..6570cf3192 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # View the makefile commands during build #set(CMAKE_VERBOSE_MAKEFILE on) -list(APPEND DEPENDENCIES realsense2) +list( APPEND DEPENDENCIES realsense2 rsutils ) if(BUILD_TOOLS) add_subdirectory(convert) diff --git a/tools/rosbag-inspector/CMakeLists.txt b/tools/rosbag-inspector/CMakeLists.txt index 44907ca77f..20a5594108 100644 --- a/tools/rosbag-inspector/CMakeLists.txt +++ b/tools/rosbag-inspector/CMakeLists.txt @@ -6,56 +6,53 @@ cmake_minimum_required(VERSION 2.8.3...3.20.5) project(RealsenseToolsRosbagInspector) -if(BUILD_GRAPHICAL_EXAMPLES) - - set(RS_ROSBAG_INSPECTOR_CPP - rs-rosbag-inspector.cpp - files_container.h - print_helpers.h - rosbag_content.h - ../../common/os.h - ../../common/os.cpp - ../../third-party/glad/glad.c - ../../third-party/imgui/imgui.cpp - ../../third-party/imgui/imgui_draw.cpp - ../../third-party/imgui/imgui_impl_glfw.cpp - ../../third-party/imgui/imgui-fonts-karla.hpp - ../../third-party/imgui/imgui-fonts-fontawesome.hpp - ../../third-party/tinyfiledialogs/tinyfiledialogs.c - ../../third-party/tinyfiledialogs/tinyfiledialogs.h - ) - - if(WIN32) - add_executable(rs-rosbag-inspector WIN32 ${RS_ROSBAG_INSPECTOR_CPP}) - include_directories(../../third-party/imgui ../../common ../../third-party/glad - ../../third-party/tinyfiledialogs ../../third-party ${CMAKE_CURRENT_SOURCE_DIR}/res/) - else() - add_executable(rs-rosbag-inspector ${RS_ROSBAG_INSPECTOR_CPP}) - include_directories(../../third-party/imgui ../../common ../../third-party/glad - ../../third-party/tinyfiledialogs ../../third-party) - endif() - set_property(TARGET rs-rosbag-inspector PROPERTY CXX_STANDARD 11) - - target_include_directories(rs-rosbag-inspector PRIVATE - ${ROSBAG_HEADER_DIRS} - ${BOOST_INCLUDE_PATH} - ${LZ4_INCLUDE_PATH} - ) - - target_link_libraries(rs-rosbag-inspector realsense-file ${DEPENDENCIES}) - - set_target_properties (rs-rosbag-inspector PROPERTIES - FOLDER Tools +set(RS_ROSBAG_INSPECTOR_CPP + rs-rosbag-inspector.cpp + files_container.h + print_helpers.h + rosbag_content.h + ../../common/os.h + ../../common/os.cpp + ../../third-party/glad/glad.c + ../../third-party/imgui/imgui.cpp + ../../third-party/imgui/imgui_draw.cpp + ../../third-party/imgui/imgui_impl_glfw.cpp + ../../third-party/imgui/imgui-fonts-karla.hpp + ../../third-party/imgui/imgui-fonts-fontawesome.hpp + ../../third-party/tinyfiledialogs/tinyfiledialogs.c + ../../third-party/tinyfiledialogs/tinyfiledialogs.h ) - using_easyloggingpp( rs-rosbag-inspector SHARED ) +if(WIN32) + add_executable(rs-rosbag-inspector WIN32 ${RS_ROSBAG_INSPECTOR_CPP}) + include_directories(../../third-party/imgui ../../common ../../third-party/glad + ../../third-party/tinyfiledialogs ../../third-party ${CMAKE_CURRENT_SOURCE_DIR}/res/) +else() + add_executable(rs-rosbag-inspector ${RS_ROSBAG_INSPECTOR_CPP}) + include_directories(../../third-party/imgui ../../common ../../third-party/glad + ../../third-party/tinyfiledialogs ../../third-party) +endif() +set_property(TARGET rs-rosbag-inspector PROPERTY CXX_STANDARD 11) - install( - TARGETS +target_include_directories(rs-rosbag-inspector PRIVATE + ${ROSBAG_HEADER_DIRS} + ${BOOST_INCLUDE_PATH} + ${LZ4_INCLUDE_PATH} + ) - rs-rosbag-inspector +target_link_libraries(rs-rosbag-inspector realsense-file ${DEPENDENCIES}) - RUNTIME DESTINATION - ${CMAKE_INSTALL_BINDIR} - ) -endif() +set_target_properties (rs-rosbag-inspector PROPERTIES + FOLDER Tools +) + +using_easyloggingpp( rs-rosbag-inspector SHARED ) + +install( + TARGETS + + rs-rosbag-inspector + + RUNTIME DESTINATION + ${CMAKE_INSTALL_BINDIR} +) diff --git a/unit-tests/CMakeLists.txt b/unit-tests/CMakeLists.txt index 42c7b6fe1a..eea8117d05 100644 --- a/unit-tests/CMakeLists.txt +++ b/unit-tests/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1.0) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -set(DEPENDENCIES realsense2) +set( DEPENDENCIES realsense2 rsutils ) find_package (Python3 COMPONENTS Interpreter Development) if (NOT ${BUILD_EASYLOGGINGPP}) diff --git a/unit-tests/unit-test-config.py b/unit-tests/unit-test-config.py index 24bb166bc5..97da9d3581 100644 --- a/unit-tests/unit-test-config.py +++ b/unit-tests/unit-test-config.py @@ -256,7 +256,7 @@ def process_cpp( dir, builddir ): shared = False static = False custom_main = False - dependencies = 'realsense2' + dependencies = 'realsense2 rsutils' for cmake_directive in file.grep( '^//#cmake:\s*', dir + '/' + f ): m = cmake_directive['match'] index = cmake_directive['index'] diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index 4968f13a72..51cd35498f 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.1.0) project(RealsenseWrappers) -set(DEPENDENCIES realsense2) +set(DEPENDENCIES realsense2 rsutils) if (BUILD_PYTHON_BINDINGS OR BUILD_PYTHON_DOCS) if (NOT INTERNET_CONNECTION)