mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2025-12-20 04:20:04 +01:00
pkg: Check INCLUDE environment variable for MSVC
On Windows builds when --msvc-syntax is in use, add paths in the INCLUDE environment variable to the system include search path and ignore the various GCC environment variables. See https://msdn.microsoft.com/en-us/library/73f9s62w.aspx for details. https://bugs.freedesktop.org/show_bug.cgi?id=94729
This commit is contained in:
parent
1dfe95b8b8
commit
df6e4b6cf1
3 changed files with 62 additions and 20 deletions
|
|
@ -39,9 +39,28 @@ run_test --cflags system
|
||||||
RESULT="-L/usr/lib -lsystem"
|
RESULT="-L/usr/lib -lsystem"
|
||||||
run_test --libs system
|
run_test --libs system
|
||||||
|
|
||||||
# Now check that the various compiler environment variables also update
|
# Now check that the various GCC environment variables also update the
|
||||||
# the system include path
|
# system include path
|
||||||
for var in CPATH C_INCLUDE_PATH CPP_INCLUDE_PATH; do
|
for var in CPATH C_INCLUDE_PATH CPP_INCLUDE_PATH; do
|
||||||
RESULT=""
|
RESULT=""
|
||||||
eval $var=/usr/include run_test --cflags system
|
eval $var=/usr/include run_test --cflags system
|
||||||
|
|
||||||
|
# Make sure these are not skipped in --msvc-syntax mode
|
||||||
|
if [ "$native_win32" = yes ]; then
|
||||||
|
RESULT="-I/usr/include"
|
||||||
|
eval $var=/usr/include run_test --cflags --msvc-syntax system
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check that the various MSVC environment variables also update the
|
||||||
|
# system include path when --msvc-syntax is in use
|
||||||
|
for var in INCLUDE; do
|
||||||
|
RESULT="-I/usr/include"
|
||||||
|
eval $var=/usr/include run_test --cflags system
|
||||||
|
|
||||||
|
# Make sure these are skipped in --msvc-syntax mode
|
||||||
|
if [ "$native_win32" = yes ]; then
|
||||||
|
RESULT=""
|
||||||
|
eval $var=/usr/include run_test --cflags --msvc-syntax system
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
10
pkg-config.1
10
pkg-config.1
|
|
@ -332,7 +332,15 @@ This is normally
|
||||||
Additional paths to append to
|
Additional paths to append to
|
||||||
.IR "PKG_CONFIG_SYSTEM_INCLUDE_PATH" .
|
.IR "PKG_CONFIG_SYSTEM_INCLUDE_PATH" .
|
||||||
These correspond to environment variables used by many compilers to
|
These correspond to environment variables used by many compilers to
|
||||||
affect the header search path.
|
affect the header search path. These are ignored on Windows builds when
|
||||||
|
\-\-msvc-syntax is in use.
|
||||||
|
.TP
|
||||||
|
.I "INCLUDE"
|
||||||
|
Additional paths to append to
|
||||||
|
.IR "PKG_CONFIG_SYSTEM_INCLUDE_PATH"
|
||||||
|
on Windows builds when \-\-msvc-syntax is in use. This corresponds to
|
||||||
|
the environment variable used by MSVC to add directories to the include
|
||||||
|
file search path.
|
||||||
.TP
|
.TP
|
||||||
.I "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"
|
.I "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"
|
||||||
Don't strip system paths out of Cflags. See
|
Don't strip system paths out of Cflags. See
|
||||||
|
|
|
||||||
49
pkg.c
49
pkg.c
|
|
@ -621,6 +621,25 @@ add_env_variable_to_list (GList *list, const gchar *env)
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Well known compiler include path environment variables. These are
|
||||||
|
* used to find additional system include paths to remove. See
|
||||||
|
* https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html. */
|
||||||
|
static const gchar *gcc_include_envvars[] = {
|
||||||
|
"CPATH",
|
||||||
|
"C_INCLUDE_PATH",
|
||||||
|
"CPP_INCLUDE_PATH",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
/* MSVC include path environment variables. See
|
||||||
|
* https://msdn.microsoft.com/en-us/library/73f9s62w.aspx. */
|
||||||
|
static const gchar *msvc_include_envvars[] = {
|
||||||
|
"INCLUDE",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
verify_package (Package *pkg)
|
verify_package (Package *pkg)
|
||||||
{
|
{
|
||||||
|
|
@ -634,6 +653,8 @@ verify_package (Package *pkg)
|
||||||
GHashTable *visited;
|
GHashTable *visited;
|
||||||
int count;
|
int count;
|
||||||
const gchar *search_path;
|
const gchar *search_path;
|
||||||
|
const gchar **include_envvars;
|
||||||
|
const gchar **var;
|
||||||
|
|
||||||
/* Be sure we have the required fields */
|
/* Be sure we have the required fields */
|
||||||
|
|
||||||
|
|
@ -743,8 +764,8 @@ verify_package (Package *pkg)
|
||||||
|
|
||||||
g_list_free (requires);
|
g_list_free (requires);
|
||||||
|
|
||||||
/* We make a list of system directories that gcc expects so we can remove
|
/* We make a list of system directories that compilers expect so we
|
||||||
* them.
|
* can remove them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
search_path = g_getenv ("PKG_CONFIG_SYSTEM_INCLUDE_PATH");
|
search_path = g_getenv ("PKG_CONFIG_SYSTEM_INCLUDE_PATH");
|
||||||
|
|
@ -756,22 +777,16 @@ verify_package (Package *pkg)
|
||||||
|
|
||||||
system_directories = add_env_variable_to_list (system_directories, search_path);
|
system_directories = add_env_variable_to_list (system_directories, search_path);
|
||||||
|
|
||||||
search_path = g_getenv ("CPATH");
|
#ifdef G_OS_WIN32
|
||||||
if (search_path != NULL)
|
include_envvars = msvc_syntax ? msvc_include_envvars : gcc_include_envvars;
|
||||||
|
#else
|
||||||
|
include_envvars = gcc_include_envvars;
|
||||||
|
#endif
|
||||||
|
for (var = include_envvars; *var != NULL; var++)
|
||||||
{
|
{
|
||||||
system_directories = add_env_variable_to_list (system_directories, search_path);
|
search_path = g_getenv (*var);
|
||||||
}
|
if (search_path != NULL)
|
||||||
|
system_directories = add_env_variable_to_list (system_directories, search_path);
|
||||||
search_path = g_getenv ("C_INCLUDE_PATH");
|
|
||||||
if (search_path != NULL)
|
|
||||||
{
|
|
||||||
system_directories = add_env_variable_to_list (system_directories, search_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
search_path = g_getenv ("CPLUS_INCLUDE_PATH");
|
|
||||||
if (search_path != NULL)
|
|
||||||
{
|
|
||||||
system_directories = add_env_variable_to_list (system_directories, search_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue