libsndfile / libsamplerate

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

Deprecation warning CMP0091 #179

Closed Alastair0100 closed 1 year ago

Alastair0100 commented 1 year ago

Cmake reports:

`"CMake Deprecation Warning at vendor/libsamplerate/CMakeLists.txt:16 (cmake_policy):The OLD behavior for policy CMP0091 will be removed from a future version of CMake.

The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD.",`

It states how the policy CMP0091 will be removed in the future. And shows a warning in the problems tab of vscode.

evpobr commented 1 year ago

Hi @Alastair0100 . I don't see this warning:

[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is MSVC 19.34.31933.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Looking for stdbool.h
[cmake] -- Looking for stdbool.h - found
[cmake] -- Looking for unistd.h
[cmake] -- Looking for unistd.h - not found
[cmake] -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
[cmake] -- Checking processor clipping capabilities...
[cmake] -- Performing Test CPU_CLIPS_POSITIVE
[cmake] -- Performing Test CPU_CLIPS_POSITIVE - Failed
[cmake] -- Performing Test CPU_CLIPS_NEGATIVE
[cmake] -- Performing Test CPU_CLIPS_NEGATIVE - Failed
[cmake] -- Checking processor clipping capabilities... none
[cmake] -- Performing Test HAVE_VISIBILITY
[cmake] -- Performing Test HAVE_VISIBILITY - Failed
[cmake] -- Looking for sys/times.h
[cmake] -- Looking for sys/times.h - not found
[cmake] -- Looking for alarm
[cmake] -- Looking for alarm - not found
[cmake] -- Looking for signal
[cmake] -- Looking for signal - found
[cmake] -- Looking for SIGALRM
[cmake] -- Looking for SIGALRM - not found
[cmake] -- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR) 
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: D:/source/repos/libsamplerate/build

Latest master, CMake 3.24, Windows 10.

Alastair0100 commented 1 year ago

Hi. I've been performing some extra tests and got some more information on this issue.

This is my output from the Output using a blank project with libsamplerate added.

[variant] Loaded new set of variants

[kit] Successfully loaded 1 kits from /home/computer/.local/share/CMakeTools/cmake-tools-kits.json

[proc] Executing command: /usr/bin/gcc -v

[proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT

[proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT

[main] Configuring folder: proj 

[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/computer/Documents/proj -B/home/computer/Documents/proj/build -G "Unix Makefiles"

[cmake] CMake Deprecation Warning at libsamplerate/CMakeLists.txt:16 (cmake_policy):

[cmake]   The OLD behavior for policy CMP0091 will be removed from a future version

[cmake]   of CMake.

[cmake] 

[cmake]   The cmake-policies(7) manual explains that the OLD behaviors of all

[cmake]   policies are deprecated and that a policy should be set to OLD only under

[cmake]   specific short-term circumstances.  Projects should be ported to the NEW

[cmake]   behavior and not rely on setting a policy to OLD.

[cmake] 

[cmake] 

[cmake] Not searching for unused variables given on the command line.

[cmake] -- Checking processor clipping capabilities...

[cmake] -- Checking processor clipping capabilities... none

[cmake] -- Configuring done

[cmake] -- Generating done

[cmake] -- Build files have been written to: /home/computer/Documents/proj/build

My CMakeLists.txt for the blank project

cmake_minimum_required(VERSION 3.8)

project(test)

set(BUILD_SHARED_LIBS OFF)

add_subdirectory(libsamplerate EXCLUDE_FROM_ALL)

add_executable(test main.cpp)

include_directories(test PRIVATE libsamplerate/include/ )

target_link_libraries(test PRIVATE samplerate)

Using cmake version 3.24.3 Arch linux. kernal - 6.0.8 Compiler gcc (GCC) 12.2.0 vscode version 1.73.1 - Cmake extension version v0.0.17 - Cmake Tools extension version v1.12.27

Anyone else having same issue?

Maybe this issue only happens when using GCC.

evpobr commented 1 year ago

Can you replace this code:

if(POLICY CMP0091)
  if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
    cmake_policy(SET CMP0091 NEW)
  else()
    cmake_policy(SET CMP0091 OLD)
  endif()
endif()

with

if(POLICY CMP0091)
  cmake_policy(SET CMP0091 NEW)
endif()

and check again?

Alastair0100 commented 1 year ago

Can you replace this code:

if(POLICY CMP0091)
  if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
    cmake_policy(SET CMP0091 NEW)
  else()
    cmake_policy(SET CMP0091 OLD)
  endif()
endif()

with

if(POLICY CMP0091)
  cmake_policy(SET CMP0091 NEW)
endif()

and check again?

Hi. Can confirm this fixes the issue! "No problems have been detected in the workspace." Thanks!~