diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in
index cad85ff979f8..ed111909b603 100644
--- a/Documentation/Doxyfile.in
+++ b/Documentation/Doxyfile.in
@@ -791,7 +791,9 @@ WARN_LOGFILE           =
 # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = "@TOP_SRCDIR@/include/libcamera" "@TOP_SRCDIR@/src/libcamera"
+INPUT                  = "@TOP_SRCDIR@/include/libcamera" \
+			 "@TOP_SRCDIR@/src/libcamera" \
+			 "@TOP_BUILDDIR@/src/libcamera"
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index 6f81f1117318..bafa103d141b 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -14,15 +14,9 @@ libcamera_api = files([
     'signal.h',
     'stream.h',
     'timer.h',
+    'version.h',
 ])
 
-gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh')
-
-version_h = vcs_tag(command : [gen_version, meson.current_source_dir()],
-                    input : 'version.h.in',
-                    output : 'version.h',
-                    fallback : 'v0.0')
-
 gen_header = files('gen-header.sh')
 
 libcamera_h = custom_target('gen-header',
diff --git a/include/libcamera/version.h.in b/include/libcamera/version.h
similarity index 79%
rename from include/libcamera/version.h.in
rename to include/libcamera/version.h
index e49b36962aed..75d57d48af0d 100644
--- a/include/libcamera/version.h.in
+++ b/include/libcamera/version.h
@@ -3,16 +3,12 @@
  * Copyright (C) 2019, Google Inc.
  *
  * version.h - Library version information
- *
- * This file is auto-generated. Do not edit.
  */
 #ifndef __LIBCAMERA_VERSION_H__
 #define __LIBCAMERA_VERSION_H__
 
 #include <string>
 
-#define LIBCAMERA_VERSION "@VCS_TAG@"
-
 namespace libcamera {
 
 extern const std::string version;
diff --git a/meson.build b/meson.build
index 342b3cc76a93..271b538bdae8 100644
--- a/meson.build
+++ b/meson.build
@@ -1,8 +1,6 @@
 project('libcamera', 'c', 'cpp',
     meson_version : '>= 0.40',
-    version : run_command('utils/gen-version.sh',
-                          '@0@'.format(meson.source_root()),
-                          check : true).stdout().strip(),
+    version : 'v0.0',
     default_options : [
         'werror=true',
         'warning_level=2',
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index c5da46b4062d..69503c6e8726 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -26,11 +26,6 @@ namespace libcamera {
 
 LOG_DEFINE_CATEGORY(Camera)
 
-/**
- * \brief The library global version string
- */
-const std::string version(LIBCAMERA_VERSION);
-
 /**
  * \class CameraManager
  * \brief Provide access and manage all cameras in the system
diff --git a/utils/gen-version.sh b/src/libcamera/gen-version.sh
similarity index 100%
rename from utils/gen-version.sh
rename to src/libcamera/gen-version.sh
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index 336f4f066fac..c35ecb988d72 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -79,8 +79,14 @@ control_types_cpp = custom_target('control_types_cpp',
 
 libcamera_sources += control_types_cpp
 
+version_cpp = vcs_tag(command : ['gen-version.sh', meson.source_root()],
+                      input : 'version.cpp.in',
+                      output : 'version.cpp',
+                      fallback : meson.project_version())
+
+libcamera_sources += version_cpp
+
 libcamera_deps = [
-    declare_dependency(sources : version_h),
     cc.find_library('dl'),
     libudev,
 ]
diff --git a/src/libcamera/version.cpp.in b/src/libcamera/version.cpp.in
new file mode 100644
index 000000000000..055dc0b5c5ad
--- /dev/null
+++ b/src/libcamera/version.cpp.in
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * version.cpp - libcamera version
+ *
+ * This file is auto-generated. Do not edit.
+ */
+
+#include <libcamera/version.h>
+
+/**
+ * \file version.h
+ * \brief libcamera version
+ */
+
+namespace libcamera {
+
+/**
+ * \var libcamera::version
+ * \brief The library global version string
+ */
+const std::string version("@VCS_TAG@");
+
+} /* namespace libcamera */
