diff --git a/doc/doxygen/meson.build b/doc/doxygen/meson.build
index b500bac41de90bf0e2f075e08b1d6082fc18f36c..e3062e30352e76fbbccd8bdc6c7f2263ec63a915 100644
--- a/doc/doxygen/meson.build
+++ b/doc/doxygen/meson.build
@@ -8,31 +8,34 @@ doc_layout_files = files([
   'footer.html'
 ])
 
-doxygen = find_program('doxygen', required : false)
 
 #Build a Doxyfile based on Doxyfile.in
 cdata_doc = configuration_data()
 cdata_doc.set('VERSION', meson.project_version())
-cdata_doc.set('SRCDIR', meson.project_source_root())
-cdata_doc.set('BUILDDIR', meson.project_build_root())
+cdata_doc.set('SRCDIR', meson.source_root())
+cdata_doc.set('BUILDDIR', meson.build_root())
 if find_program('dot', required : false).found()
   cdata_doc.set('HAVE_DOT', 'YES')
 else
   cdata_doc.set('HAVE_DOT', 'NO')
 endif
 
-doxy_file = configure_file(
-  input : 'Doxyfile.in',
-  output : 'Doxyfile',
-  configuration : cdata_doc,
-  install : false,
-)
+doxygen = find_program('doxygen', required : false)
+
+if doxygen.found()
+  doxy_file = configure_file(
+    input : 'Doxyfile.in',
+    output : 'Doxyfile',
+    configuration : cdata_doc,
+    install : false,
+  )
 
-custom_target('doc',
-  input : doxy_file,
-  output : 'html',
-  depend_files : [doc_layout_files, main, cmplib_sources],
-  command : [doxygen, '@INPUT@'],
-  build_by_default : false,
-  console : true,
-)
+  custom_target('doc',
+    input : doxy_file,
+    output : 'html',
+    depend_files : [doc_layout_files, main, cmplib_sources],
+    command : [doxygen, '@INPUT@'],
+    build_by_default : false,
+    console : true,
+  )
+endif