Skip to content

FindPkgConfig: Fails to find pkg-config if $PKG_CONFIG contains spaces

I have $PKG_CONFIG set to pkgconf --keep-system-libs --keep-system-cflags --static in order to make sure pkgconfig will always at least output an include directory and lib directory and also provide the private dependencies, however, if I run cmake -B builddir -GNinja with a CMakeLists.txt of

project(a)

find_package(PkgConfig)

cmake outputs

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
    Reason given by package: The command
      "D:/msys64/mingw64/bin/pkgconf --keep-system-libs --static" --version
    failed with output:

    stderr:

    result:
The system cannot find the file specified

for linux

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
    Reason given by package: The command
      "pkgconf --keep-system-libs --keep-system-cflags --static" --version
    failed with output:

    stderr: 
      
    result: 
No such file or directory

For cmake specifically, I have to use a batch file or bash file wrapper in order to make sure it passes the default arguments that I want.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information