How to fix cmake < 3.5 compatibility error

Trying to install obs-ghostscript from Aur I get the following error:

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

What are the needed steps to ;

 Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

thank you for your help!

You didn’t mention which package you are trying to build.
You can try manually building by modifying the PKGBUILD to CMAKE instead of CMAKE >3.5.

Thank you for your reply!
The package is obs-ghostscript

Introduced to AUR - and last updated - on the same day 3.5 years ago.

AUR (en) - obs-ghostscript

Who knows whether it ever worked …
No votes, popularity zero, no comments

The source of it is even older:

GitHub - nleseul/obs-ghostscript: Video source plugin for OBS which renders PDF and other documents using Ghostscript

You’ll likely need to fix the PKGBUILD yourself.

There might be a different way today to achieve what this was doing - but I don’t know.
I have never used obs.

I want to try but I need some help

Perhaps a different way of doing it is easier than to try and compile the plugin …?

insert a PDF in OBS STUDIO | OBS Forums

As I said: I don’t have the first clue about obs and making presentations with it, but this sounds like a reasonable alternative way of achieving what this plugin does.

Can’t help with the PKGBUILD - I’d first try to compile without it, from source
and once it works, use what you learned about the options and needed steps to translate that into the PKGBUILD.

It’s likely a lot of work and a steep learning curve for you.
Perhaps the source is just too old to make it work with the modern tools Arch and Manjaro uses? :man_shrugging:

Even with using the -DCMAKE_POLICY_VERSION_MINIMUM='3.5' Cmake flag, it appears it will need upstream changes for GCC 14. Doesn’t seem likely since there’s been no upstream activity in about 5 years.

[ 50%] Building C object CMakeFiles/obs-ghostscript.dir/src/obs-ghostscript.c.o
/build/obs-ghostscript/src/obs-ghostscript-1.3/src/obs-ghostscript.c: In function ‘ghostscript_display_page’:
/build/obs-ghostscript/src/obs-ghostscript-1.3/src/obs-ghostscript.c:115:37: error: passing argument 5 of ‘gs_texture_create’ from incompatible pointer type [-Wincompatible-pointer-types]
  115 |                         GS_BGRX, 1, &context->cached_raster, GS_DYNAMIC);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~
      |                                     |
      |                                     unsigned char **
In file included from /usr/include/obs/obs.h:24,
                 from /usr/include/obs/obs-module.h:20,
                 from /build/obs-ghostscript/src/obs-ghostscript-1.3/src/obs-ghostscript.c:1:
/usr/include/obs/graphics/graphics.h:619:73: note: expected ‘const uint8_t **’ {aka ‘const unsigned char **’} but argument is of type ‘unsigned char **’
  619 |                                        uint32_t levels, const uint8_t **data, uint32_t flags);
      |                                                         ~~~~~~~~~~~~~~~~^~~~
make[2]: *** [CMakeFiles/obs-ghostscript.dir/build.make:79: CMakeFiles/obs-ghostscript.dir/src/obs-ghostscript.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/obs-ghostscript.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
1 Like

That can avoided using:

  export CFLAGS+=" -Wno-incompatible-pointer-types"
  export CXXFLAGS+=" -Wno-incompatible-pointer-types"
2 Likes

Yep, that worked. Here’s the diff:

--- PKGBUILD-old	2025-04-26 11:03:28.387316931 -0600
+++ PKGBUILD-new	2025-04-26 11:02:53.905928978 -0600
@@ -6,9 +6,9 @@
 pkgdesc="OBS Plugin to allow inclusion of PDF documents in scenes"
 arch=('x86_64' 'i686')
 url="https://github.com/nleseul/${pkgname}"
-license=('Unlincense')
+license=('Unlicense')
 depends=('obs-studio' 'ghostscript')
-makedepends=('make')
+makedepends=('cmake')
 source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
 sha256sums=('ef06d36d1ce42515f89cd56180aa38f4aaad612f28feb5d8e90cbe4d6bfba078')
 
@@ -19,19 +19,20 @@
 }
 
 build() {
-    cd "$pkgname-$pkgver"
-    mkdir -p build
-    cd build
-    cmake .. \
-        -DOBSSourcePath=/usr/include/obs/ \
-        -DOBSLibraryPath=/usr/lib/obs-plugins/ \
-        -DCMAKE_INSTALL_PREFIX='/usr'
-    make
+    export CFLAGS+=" -Wno-incompatible-pointer-types"
+    export CXXFLAGS+=" -Wno-incompatible-pointer-types"
+    cmake -B build -S "$pkgname-$pkgver" \
+        -DCMAKE_BUILD_TYPE='None' \
+        -DCMAKE_INSTALL_PREFIX='/usr' \
+        -DOBSSourcePath='/usr/include/obs/' \
+        -DOBSLibraryPath='/usr/lib/obs-plugins/' \
+        -DCMAKE_POLICY_VERSION_MINIMUM='3.5' \
+        -Wno-dev
+    cmake --build build
 }
 
 package() {
-    cd "$pkgname-$pkgver/build"
-    make DESTDIR="$pkgdir/" install
+    DESTDIR="$pkgdir" cmake --install build
 }
 
 # vim:set ts=4 sw=4 et:
3 Likes

:+1: there you go, @hafid

Sorry but this isn’t a valid advice, the issue is that cmake minimum required version too low for cmake 4.0, it want at least 3.5, it can be avoided passing a cmake flag or by updating CMakeLists.txt in the source

Sorry for my ignorance! but how to use this?

Mark made a diff for the pkgbuild a couple of posts above How to fix cmake < 3.5 compatibility error - #9 by Yochanan