Bug 103203

Summary: pkg-config output with escaped spaces cannot be used by Windows cmd
Product: pkg-config Reporter: Maria <mariia.krainiuk>
Component: srcAssignee: pkg-config
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Windows (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: pc file used as an example

Description Maria 2017-10-10 22:41:00 UTC
Created attachment 134783 [details]
pc file used as an example

As I see Windows command line supports quotation marks only to escape spaces in a path. But pkg-config tool adds backslashes to escape spaces in a path.
Because of this it looks impossible to use pkg-config on Windows if include path or lib path contain spaces. 
Example without spaces:
----------------------------------------------------------------------------
C:\tmp>for /F "delims=," %i in ('pkg-config --cflags --libs win-path-wspace-test') do cl x.c %i
C:\tmp>cl x.c -IC:\\tmp/include  C:\\tmp/libs/a.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

x.c
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:x.exe
x.obj
C:\\tmp/libs/a.lib
----------------------------------------------------------------------------
Example with spaces:
----------------------------------------------------------------------------
C:\tmp>for /F "delims=," %i in ('pkg-config --cflags --libs win-path-wspace-test') do cl x.c %i
C:\tmp>cl x.c -IC:\\Program\ Files\ (x86)\\tmp/include  C:\\Program\ Files\ (x86)\\tmp/libs/a.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9024 : unrecognized source file type 'Files\', object file assumed
cl : Command line warning D9024 : unrecognized source file type '(x86)\\tmp/include', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:\\Program\', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'Files\', object file assumed
x.c
x.c(3): fatal error C1083: Cannot open include file: 'a.h': No such file or directory
----------------------------------------------------------------------------

Could you add possibility to get quotation marks for those paths on Windows that contains spaces to escape them? So that it would be much easier to work with pkg-config on Windows.

And just nice-to-have: when I set path with spaces to PKG_CONFIG_PATH Windows command line adds quotation marks to this path automatically but path with quotation marks can not be found by pkg-config tool 
From debug output:
----------------------------------------------------------------------------
C:\tmp>set PKG_CONFIG_PATH="C:\work\pkg config"
C:\tmp>pkg-config --cflags --libs --debug win-path-wspace-test
Option --debug seen
Error printing enabled by default due to use of --version, --libs, --cflags, --libs-only-l, --libs-only-L, --libs-only-other, --cflags-only-I, --cflags-only-other or --list. Value of --silence-errors: 0
Error printing enabled
Adding virtual 'pkg-config' package to list of known packages
Cannot open directory '"C:/tmp/pkg config"' in package search path: No such file or directory
----------------------------------------------------------------------------
Comment 1 GitLab Migration User 2018-08-25 12:56:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pkg-config/pkg-config/issues/43.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.