Skip to content
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

CMake improvements #163

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

onurbingol
Copy link

@onurbingol onurbingol commented Jun 29, 2023

  • This PR updates CMake configuration files to make it more modular and CMake-native.
  • There are some major changes (discussed below) in addition to the minor changes (documented in the code)

Added options

  • JU_ENABLE_PYTHON_BINDINGS enables building the python bindings
  • JU_PYTHON_BINDING_VERSION allows setting custom python version without editing python/CMakeLists.txt file
  • JU_ENABLE_CAMERA_VIEWER enables building the application under camera/camera-viewer
  • JU_ENABLE_V4L2_DISPLAY enables building the application under camera/v4l2-display
  • JU_ENABLE_V4L2_CONSOLE enables building the application under camera/v4l2-console
  • JU_ENABLE_VIDEO_VIEWER enables building the application under video/video-viewer
  • JU_ENABLE_GL_DISPLAY_TEST enables building the application under display/gl-display-test
  • JU_ENABLE_WEBRTC_SERVER enables building the application under network/webrtc-server
  • JU_ENABLE_RTSP_SERVER enables building the application under network/rtsp-server

It is possible to use CMAKE_INSTALL_PREFIX to change the installation directory. This option also works if jetson-utils project is added as a submodule and install prefix is changed from the parent.

By default jetson-utils use C++11, but if it is set to a different standard at the parent level, it will use it.

Usage example

$ mkdir -p build
$ cd build
$ cmake .. -DJU_ENABLE_PYTHON_BINDINGS=ON -DJU_PYTHON_BINDING_VERSION=3.9

Note: You would also be able to see all the options under JU prefix if you use cmake-gui.

Added build targets

If you are building jetson-utils as a standalone project, you should be able to have an option for uninstall, i.e.

$ cd build
$ make uninstall

CMake example on how to use jetson-utils library

cmake_minimum_required(VERSION 3.11)
project(my_project LANGUAGES CXX VERSION 1.0)

include(GNUInstallDirs)
include(FetchContent) 

FetchContent_Declare(
  jetson-utils
  GIT_REPOSITORY https://github.com/onurbingol/jetson-utils.git
  GIT_TAG        onur/cmake-improvements
)
FetchContent_MakeAvailable(jetson-utils)

# the executable name would be "my_project_app"
cuda_add_executable(${PROJECT_NAME}_app
  ${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
)
target_link_libraries(${PROJECT_NAME}_app
  jetson-utils
)

install(
  TARGETS
    ${PROJECT_NAME}_app
  DESTINATION
    ${CMAKE_INSTALL_BINDIR}
)

@onurbingol onurbingol marked this pull request as ready for review August 5, 2023 01:24
@onurbingol
Copy link
Author

@dusty-nv this is almost done, I need to test a little bit more. I'd be happy if you could also test the final changes.

@onurbingol
Copy link
Author

@dusty-nv tested on Jetson Nano and Jetson Orin Nano, it looks good to me. Also added some details on the changes I made. There are no changes in the code, just the CMakeLists.txt files.

You might see that there are no __init__.py files in the repo. Those files can be configured/created automatically by CMake, which seems a more convenient solution to me (git complains about those __init__.py files when the OS is using a case insensitive file system)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant