Skip to content

CMAKE Build error on Windows - Could NOT find PkgConfig #224

@fred-rabelo

Description

@fred-rabelo

Hello,

I am trying to integrate the libsamplerate to my project via CMAKE but no success.

Runing on:
Windows 11
Cmake 3.31.3
CPM.cmake 0.40.5
Visual Studio 2022

Error:

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

cmake file:

cmake_minimum_required(VERSION 3.24)

project(test VERSION 0.1.0)

set(LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs)                   # Set the path to install the libraries


# ADD CPM  :::::::::

set(CPM_DOWNLOAD_VERSION 0.40.5)
set(CPM_DOWNLOAD_LOCATION "${LIB_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")

message(STATUS "Looking for CPM.make...")
if (NOT EXISTS ${CPM_DOWNLOAD_LOCATION})
    message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
    file(DOWNLOAD 
        https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake 
        ${CPM_DOWNLOAD_LOCATION})
    include(${CPM_DOWNLOAD_LOCATION})
else()
    message(STATUS "CPM.make already installed at: ${CPM_DOWNLOAD_LOCATION}")
endif ()

include(${CPM_DOWNLOAD_LOCATION})

# ADD libsamplerate ::::::

CPMAddPackage(
  NAME              libsamplerate   # The unique name of the dependency (should be the exported target's name)
  GIT_REPOSITORY    https://github.com/libsndfile/libsamplerate
  GIT_TAG           "0.2.2"
  #OPTIONS           "CMAKE_BUILD_TYPE Release" # Configuration options passed to the dependency (optional)
  SOURCE_DIR        ${LIB_DIR}/libsamplerate
  #DOWNLOAD_ONLY     True
  OPTIONS           "BUILD_TESTING OFF"
)

# once build is working
#
# add_executable(test test/test.cpp) 
# link and include lib
# 

Found one related topic: #162

1 - Do i understand correctly that pck_config is not compatible with windows?

2 - Am managing the dependency to the libsamplerate right?
What i see is that CPMaddPackage clones the rep and runs the cmake file in it. Which should run smoothly no?

I was able to build the lib myself without cmake though...

3 - I also tried downloading the release from here but linking to that i get the error: samplerate.dll was not found.
So i am guessing this is not a static build, right?
Is there a "static pre built binaries release"?

4 - should i just use fetch_content and add_library instead?
seems a little bit too complicated since libsamplerate is already configured for cmake.

Thanks for any help and for this Project!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions