Add a #define HAVE_MSYSTEM and use it

In certain situations using __MINGW64__ is not correct.
We want to have the condition apply using MinGW-w64 but also
using MSYS2, which the __MINGW64__ condition alone does not
capture.

Add a HAVE_MSYSTEM C define and use it where appropriate.
This commit is contained in:
João Valverde 2023-02-06 16:09:54 +00:00
parent 66bd99f1a8
commit 7c156d9ac4
4 changed files with 12 additions and 8 deletions

View File

@ -32,6 +32,7 @@ if(WIN32)
message(STATUS "Using 3rd party repository")
endif()
set(USE_MSYSTEM ${_msystem} CACHE INTERNAL "Use MSYS2 subsystem")
set(HAVE_MSYSTEM ${USE_MSYSTEM}) # For config.h
set(USE_REPOSITORY ${_repository} CACHE INTERNAL "Use Wireshark 3rd Party Repository")
endif()

View File

@ -309,6 +309,9 @@
/* Define to 1 if the 'ssize_t' type exists. */
#cmakedefine HAVE_SSIZE_T 1
/* Define to 1 if we are using the msys2 environment to build. */
#cmakedefine HAVE_MSYSTEM 1
#if defined(_MSC_VER)
# define strncasecmp strnicmp
# define popen _popen

View File

@ -342,7 +342,7 @@ check_and_warn_user_startup()
}
#endif
#if defined(_WIN32) && !defined(__MINGW64__)
#if defined(_WIN32) && !defined(HAVE_MSYSTEM)
// Try to avoid library search path collisions. QCoreApplication will
// search QT_INSTALL_PREFIX/plugins for platform DLLs before searching
// the application directory. If
@ -650,7 +650,7 @@ int main(int argc, char *qt_argv[])
commandline_early_options(argc, argv);
#if defined(_WIN32) && !defined(__MINGW64__)
#if defined(_WIN32) && !defined(HAVE_MSYSTEM)
win32_reset_library_path();
#endif

View File

@ -642,7 +642,7 @@ configuration_init_w32(const char* arg0 _U_)
msg, error);
}
#ifdef __MINGW64__
#ifdef HAVE_MSYSTEM
/*
* We already have the program_dir. Find the installation prefix.
* This is one level up from the bin_dir. If the program_dir does
@ -657,7 +657,7 @@ configuration_init_w32(const char* arg0 _U_)
install_prefix = g_strdup(progfile_dir);
running_in_build_directory_flag = TRUE;
}
#endif /* __MINGW64__ */
#endif /* HAVE_MSYSTEM */
return NULL;
}
@ -994,7 +994,7 @@ get_datafile_dir(void)
return datafile_dir;
}
#if defined(__MINGW64__)
#if defined(HAVE_MSYSTEM)
if (running_in_build_directory_flag) {
datafile_dir = g_strdup(install_prefix);
} else {
@ -1072,7 +1072,7 @@ get_doc_dir(void)
;
}
#if defined(__MINGW64__)
#if defined(HAVE_MSYSTEM)
if (running_in_build_directory_flag) {
doc_dir = g_strdup(install_prefix);
} else {
@ -1157,7 +1157,7 @@ init_plugin_dir(void)
}
#if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
#if defined(__MINGW64__)
#if defined(HAVE_MSYSTEM)
if (running_in_build_directory_flag) {
plugin_dir = g_build_filename(install_prefix, "plugins", (gchar *)NULL);
} else {
@ -1311,7 +1311,7 @@ init_extcap_dir(void)
extcap_dir = g_strdup(g_getenv(extcap_dir_envar));
}
#if defined(__MINGW64__)
#if defined(HAVE_MSYSTEM)
else if (running_in_build_directory_flag) {
extcap_dir = g_build_filename(install_prefix, "extcap", (gchar *)NULL);
} else {