libsndfile / libsamplerate

An audio Sample Rate Conversion library
http://libsndfile.github.io/libsamplerate/
BSD 2-Clause "Simplified" License
600 stars 167 forks source link

Use interface target instead of alias for fftw3 #192

Closed bclswl0827 closed 1 year ago

bclswl0827 commented 1 year ago

This PR fix a bug when running cmake ..:

CMake Error at tests/CMakeLists.txt:11 (add_library):
  add_library cannot create ALIAS target "FFTW3::fftw3" because target
  "PkgConfig::FFTW3" is imported but not globally visible.

Use interface target instead of alias for fftw3 works. Test passed on CMake 3.16.3

evpobr commented 1 year ago

Hi @bclswl0827 .

bclswl0827 commented 1 year ago

I'm using Ubuntu 20.04, here is a more complete log

# user @ Yuki-PC in ~ [12:04:01] 
$ git clone https://github.com/libsndfile/libsamplerate --depth 1
Cloning into 'libsamplerate'...
remote: Enumerating objects: 113, done.
remote: Counting objects: 100% (113/113), done.
remote: Compressing objects: 100% (98/98), done.
remote: Total 113 (delta 13), reused 53 (delta 10), pack-reused 0
Receiving objects: 100% (113/113), 3.80 MiB | 3.24 MiB/s, done.
Resolving deltas: 100% (13/13), done.

# user @ Yuki-PC in ~ [12:04:09] 
$ cd libsamplerate; mkdir build; cd build; cmake ..
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for immintrin.h
-- Looking for immintrin.h - found
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'sndfile'
--   Found sndfile, version 1.0.28
-- Checking processor clipping capabilities...
-- Performing Test CPU_CLIPS_POSITIVE
-- Performing Test CPU_CLIPS_POSITIVE - Failed
-- Performing Test CPU_CLIPS_NEGATIVE
-- Performing Test CPU_CLIPS_NEGATIVE - Failed
-- Checking processor clipping capabilities... none
-- Performing Test HAVE_VISIBILITY
-- Performing Test HAVE_VISIBILITY - Success
-- Looking for sys/times.h
-- Looking for sys/times.h - found
-- Looking for alarm
-- Looking for alarm - found
-- Looking for signal
-- Looking for signal - found
-- Looking for SIGALRM
-- Looking for SIGALRM - found
-- Checking for module 'fftw3'
--   Found fftw3, version 3.3.8
CMake Error at tests/CMakeLists.txt:11 (add_library):
  add_library cannot create ALIAS target "FFTW3::fftw3" because target
  "PkgConfig::FFTW3" is imported but not globally visible.

-- Found ALSA: /usr/lib/x86_64-linux-gnu/libasound.so (found version "1.2.2") 
-- Configuring incomplete, errors occurred!
See also "/home/user/libsamplerate/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/libsamplerate/build/CMakeFiles/CMakeError.log".
evpobr commented 1 year ago

I guess the proper way is

pkg_check_modules(FFTW3 fftw3 IMPORTED_TARGET GLOBAL)

Minimum required CMake version bump is required to 3.13, but i guess it is not problem. Can you test it?

bclswl0827 commented 1 year ago

I guess the proper way is

pkg_check_modules(FFTW3 fftw3 IMPORTED_TARGET GLOBAL)

Minimum required CMake version bump is required to 3.13, but i guess it is not problem. Can you test it?

Thank you, this also works :) I originally referred to this solution

evpobr commented 1 year ago

Let's use your version.

evpobr commented 1 year ago

Thanks @bclswl0827 !