cam: Add option to report libcamera version
diff mbox series

Message ID 20260416232625.26758-1-kieran.bingham@ideasonboard.com
State New
Headers show
Series
  • cam: Add option to report libcamera version
Related show

Commit Message

Kieran Bingham April 16, 2026, 11:26 p.m. UTC
The cam tool is our swiss army knife for interogating libcamera.

A frequently needed piece of information is to determine what version of
libcamera is installed or being run on a system.

This information is available in the debug logs of libcamera when a
CameraManager is instantiated. However without actually starting the
CameraManager this information is not presented.

Add an option to 'cam' to allow it to report the version.  Whilst this
is the version from the 'cam' command, it directly gets the version of
the libcamera library to which cam is linked.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

Quite simply:

kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --version
libcamera version v0.7.0+89-ed4dd6bb-dirty (2026-04-17T00:18:37BST)


and

kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --help
Options:
  -c, --camera camera ...                               Specify which camera to operate on, by id or by index
  -h, --help                                            Display this help message
  -v, --version                                         Display libcamera version information
  -I, --info                                            Display information about stream(s)
.... <snip remaining usage help> ...



 src/apps/cam/main.cpp | 8 ++++++++
 src/apps/cam/main.h   | 1 +
 2 files changed, 9 insertions(+)

Patch
diff mbox series

diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp
index 029f518f7294..120917eb632d 100644
--- a/src/apps/cam/main.cpp
+++ b/src/apps/cam/main.cpp
@@ -126,6 +126,8 @@  int CamApp::parseOptions(int argc, char *argv[])
 			 ArgumentRequired, "camera", true);
 	parser.addOption(OptHelp, OptionNone, "Display this help message",
 			 "help");
+	parser.addOption(OptVersion, OptionNone, "Display libcamera version information",
+			 "version");
 	parser.addOption(OptInfo, OptionNone,
 			 "Display information about stream(s)", "info");
 	parser.addOption(OptList, OptionNone, "List all cameras", "list");
@@ -197,6 +199,12 @@  int CamApp::parseOptions(int argc, char *argv[])
 		return options_.empty() ? -EINVAL : -EINTR;
 	}
 
+	if (options_.isSet(OptVersion)) {
+		const std::string &version = CameraManager::version();
+		std::cout << "libcamera version " << version << std::endl;
+		return -EINTR;
+	}
+
 	return 0;
 }
 
diff --git a/src/apps/cam/main.h b/src/apps/cam/main.h
index 64e6a20e8668..9bec1e712dfb 100644
--- a/src/apps/cam/main.h
+++ b/src/apps/cam/main.h
@@ -20,6 +20,7 @@  enum {
 	OptOrientation = 'o',
 	OptSDL = 'S',
 	OptStream = 's',
+	OptVersion = 'v',
 	OptListControls = 256,
 	OptStrictFormats = 257,
 	OptMetadata = 258,