obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

Garbage in pkg-config on FreeBSD

Open jbeich opened this issue 3 years ago • 3 comments

Operating System Info

Other

Other OS

FreeBSD

OBS Studio Version

28.1.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

N/A

OBS Studio Crash Log URL

No response

Expected Behavior

$ pkg-config libobs --cflags
-I/usr/local/include/obs -DHAVE_OBSCONFIG_H -mmmx -msse -msse2 -pthread

Current Behavior

$ pkg-config libobs --cflags
-I/usr/local/include/obs -DHAVE_OBSCONFIG_H -mmmx -msse -msse2 $\<$\<COMPILE_LANG_AND_ID:CUDA,NVIDIA\>:SHELL:-Xcompiler -pthread\> $\<$\<NOT:$\<COMPILE_LANG_AND_ID:CUDA,NVIDIA\>\>:-pthread\> 

Steps to Reproduce

  1. pkg install obs-studio mercurial meson pkgconf
  2. hg clone https://hg.sr.ht/~scoopta/wlrobs
  3. cd wlrobs
  4. hg checkout v1.0
  5. meson setup _build
  6. meson compile -C _build
cc: error: unknown argument '-pthread>'; did you mean '-pthreads'?
cc: error: no such file or directory: '$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler'
cc: error: no such file or directory: '$<$<NOT:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>>:-pthread>'

Anything else we should know?

Regressed by #6746 due to not sanitizing INTERFACE_COMPILE_OPTIONS. CC @PatTheMav, @yurivict

--- /usr/local/libdata/pkgconfig/libobs.pc	before
+++ /usr/local/libdata/pkgconfig/libobs.pc	after
@@ -1,10 +1,10 @@ Version: 28.1.2
 prefix=/usr/local
 exec_prefix=${prefix}
 libdir=/usr/local/lib
 includedir=/usr/local/include/obs
 
 Name: libobs
 Description: OBS Studio Library
 Version: 28.1.2
-Cflags: -I${includedir} -DHAVE_OBSCONFIG_H  
-Libs: -L${libdir} -lpthread
+Cflags: -I${includedir} -DHAVE_OBSCONFIG_H -mmmx -msse -msse2  $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler -pthread> $<$<NOT:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>>:-pthread>
+Libs: -L${libdir} -lobs -lpthread

Note, COMPILE_LANG_AND_ID:CUDA,NVIDIA comes from Threads::Threads

jbeich avatar Dec 31 '22 17:12 jbeich

CMake does not have .pc generator because it is not possible to properly represent the transitive dependency relations of a CMake project into a single .pc file and generator expressions make it more or less required that CMake itself would generate those files at generation time (right now the file is created at configure time).

As we rely on modern CMake (and will deepen that reliance next year), this issue will become more apparent, so we'll probably deprecate generation of a pkg-config file anyway (also to keep our maintenance burden limited to platforms/toolchains we can support in a sustainable fashion).

If a project cannot use the generated CMake packages (which are fully supported) and instead need to rely on pkg-config, such projects need to maintain their own .pc file.

So while this is effectively a "Won't fix/do", I'll leave this open because it is valid within the context of the current code base.

PatTheMav avatar Dec 31 '22 17:12 PatTheMav

This is also similar to #7972.

Conan-Kudo avatar Jan 01 '23 11:01 Conan-Kudo

That is correct - having slept on it, I would prefer if we would ship handcrafted .pc files (right now only libobs ships with one, but obs-frontend-api does not, even though the latter is also optionally required for plugin development).

Those should also take optional static linking (Cflags.private) into account and required system libraries (or other dependencies provided via peg-config).

That way generator expressions from CMake should not leak into them and we could better take different architectures into account.

PatTheMav avatar Jan 01 '23 14:01 PatTheMav