summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2017-03-20 11:32:32 -0500
committerDan Nicholson <dbn.lists@gmail.com>2017-03-20 11:34:02 -0500
commitdf6e4b6cf1fc25bf768fbc03cb7a8deed266eb25 (patch)
tree9c8f82435beb4f03786f6238c3e1b1876795bf26
parent1dfe95b8b85a0d515d8c53d711dd26627859ed3f (diff)
downloadpkg-config-df6e4b6cf1fc25bf768fbc03cb7a8deed266eb25.tar.gz
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
-rwxr-xr-xcheck/check-system-flags23
-rw-r--r--pkg-config.110
-rw-r--r--pkg.c49
3 files changed, 62 insertions, 20 deletions
diff --git a/check/check-system-flags b/check/check-system-flags
index 831dd0e..632496c 100755
--- a/check/check-system-flags
+++ b/check/check-system-flags
@@ -39,9 +39,28 @@ run_test --cflags system
RESULT="-L/usr/lib -lsystem"
run_test --libs system
-# Now check that the various compiler environment variables also update
-# the system include path
+# Now check that the various GCC environment variables also update the
+# system include path
for var in CPATH C_INCLUDE_PATH CPP_INCLUDE_PATH; do
RESULT=""
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
diff --git a/pkg-config.1 b/pkg-config.1
index c8cec84..a147fc8 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -332,7 +332,15 @@ This is normally
Additional paths to append to
.IR "PKG_CONFIG_SYSTEM_INCLUDE_PATH" .
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
.I "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"
Don't strip system paths out of Cflags. See
diff --git a/pkg.c b/pkg.c
index ae630c4..f29ecc7 100644
--- a/pkg.c
+++ b/pkg.c
@@ -621,6 +621,25 @@ add_env_variable_to_list (GList *list, const gchar *env)
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
verify_package (Package *pkg)
{
@@ -634,6 +653,8 @@ verify_package (Package *pkg)
GHashTable *visited;
int count;
const gchar *search_path;
+ const gchar **include_envvars;
+ const gchar **var;
/* Be sure we have the required fields */
@@ -743,8 +764,8 @@ verify_package (Package *pkg)
g_list_free (requires);
- /* We make a list of system directories that gcc expects so we can remove
- * them.
+ /* We make a list of system directories that compilers expect so we
+ * can remove them.
*/
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);
- search_path = g_getenv ("CPATH");
- 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)
+#ifdef G_OS_WIN32
+ 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);
}
count = 0;