From 2c7d22dba279721e776a712a8e2e98981e562fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Mon, 20 Sep 2021 18:54:54 +0100 Subject: [PATCH] CMake: Fix macro redefinition of Windows API versioning --- CMakeLists.txt | 19 +++++++++++++++++++ cmakeconfig.h.in | 17 ----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 990b5dcea7..1020a99505 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -427,6 +427,25 @@ set_property(DIRECTORY $<$,$>:WS_DISABLE_DEBUG> ) +if(WIN32) + # + # Make sure everyone is using the same API and that it's sufficient + # for our needs. + # This should match the following: + # - The section in image\wireshark.exe.manifest.in + # - The GetWindowsVersion parts of packaging\nsis\wireshark.nsi + # - The VersionNT parts of packaging\wix\Prerequisites.wxi + # + # NOTE: Because of the way Qt moc is including "config.h" (not as the + # first header) this *MUST* be defined on the command line to precede + # every included header and not trigger symbol redefinition errors. + # + add_definitions( + -DNTDDI_VERSION=NTDDI_WIN7 + -D_WIN32_WINNT=_WIN32_WINNT_WIN7 + ) +endif() + if( CMAKE_C_COMPILER_ID MATCHES "MSVC") if ((MSVC_VERSION LESS "1900") OR (MSVC_VERSION GREATER_EQUAL "2000")) message(FATAL_ERROR "You are using an unsupported version of MSVC") diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index 7873d0b802..35699397a4 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -289,23 +289,6 @@ #cmakedefine YYTEXT_POINTER #if defined(_WIN32) - /* - * Make sure everyone is using the same API and that it's sufficient - * for our needs. - * This should match the following: - * - The section in image\wireshark.exe.manifest.in - * - The GetWindowsVersion parts of packaging\nsis\wireshark.nsi - * - The VersionNT parts of packaging\wix\Prerequisites.wxi - */ -# if defined(NTDDI_VERSION) -# error NTDDI_VERSION already defined. -# endif -# define NTDDI_VERSION NTDDI_WIN7 -# if defined(_WIN32_WINNT) -# error _WIN32_WINNT already defined. -# endif -# define _WIN32_WINNT _WIN32_WINNT_WIN7 - /* WpdPack/INclude/pcap/pcap.h checks for "#if defined(WIN32)" */ # ifndef WIN32 # define WIN32 1