tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / solenv / gbuild / platform / com_MSC_defs.mk
blobe915036b54c81fab23285395455fe26f05cc764f
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # please make generic Windows modifications to windows.mk
21 include $(GBUILDDIR)/platform/windows.mk
23 gb_CC := cl
24 gb_CXX := cl
25 gb_LINK := link
26 gb_DUMPBIN := dumpbin
27 gb_AWK := awk
28 gb_CLASSPATHSEP := ;
29 gb_RC := rc
31 # use CC/CXX if they are nondefaults
32 ifneq ($(origin CC),default)
33 gb_CC := $(CC)
34 gb_GCCP := $(CC)
35 endif
36 ifneq ($(origin CXX),default)
37 gb_CXX := $(CXX)
38 endif
40 # _SILENCE_CXX23_DENORM_DEPRECATION_WARNING is needed at least with Boost 1.82.0 using
41 # std::numeric_limits::has_denorm in
42 # workdir/UnpackedTarball/boost/boost/spirit/home/classic/core/primitives/impl/numerics.ipp, in turn
43 # included from boost/spirit/include/classic_core.hpp as included from various of our code files:
45 # _SCL_SECURE_NO_WARNINGS avoids deprecation warnings for STL algorithms
46 # like std::copy, std::transform (when MSVC_USE_DEBUG_RUNTIME is enabled)
48 gb_COMPILERDEFS := \
49 -DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE \
50 -DBOOST_SYSTEM_NO_DEPRECATED \
51 -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING \
52 -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING \
53 -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING \
54 -D_SILENCE_CXX23_DENORM_DEPRECATION_WARNING \
55 -D_CRT_NON_CONFORMING_SWPRINTFS \
56 -D_CRT_NONSTDC_NO_DEPRECATE \
57 -D_CRT_SECURE_NO_DEPRECATE \
58 -D_SCL_SECURE_NO_WARNINGS \
59 -D_MT \
60 -D_DLL \
61 -DCPPU_ENV=$(CPPU_ENV) \
63 ifeq ($(CPUNAME),INTEL)
64 gb_COMPILERDEFS += \
65 -DBOOST_MEM_FN_ENABLE_CDECL \
67 endif
69 gb_RCDEFS := \
70 $(gb_WIN_VERSION_DEFS) \
72 gb_RCFLAGS :=
74 gb_AFLAGS := $(AFLAGS)
76 # Do we really need to disable this many warnings? It seems to me that
77 # many of these warnings are for constructs that we have been actively
78 # cleaning away from the code, to avoid warnings when building with
79 # gcc or Clang and -Wall -Werror.
81 # C4127: conditional expression is constant
83 # C4201: nonstandard extension used : nameless struct/union
85 # C4244: 'argument' : conversion from 'type1' to 'type2', possible loss of data
87 # C4250: 'class1' : inherits 'class2::member' via dominance
89 # C4251: 'identifier' : class 'type' needs to have dll-interface to be
90 # used by clients of class 'type2'
92 # C4267: conversion from 'size_t' to 'type', possible loss of data
94 # C4275: non-DLL-interface classkey 'identifier' used as base for
95 # DLL-interface classkey 'identifier'
97 # C4505: 'function' : unreferenced local function has been removed
99 # C4611: interaction between 'function' and C++ object destruction is
100 # non-portable
102 # C4702: unreachable code
104 # C4706: assignment within conditional expression
106 # build-time penalty is too high for ci use/disable when JENKINS_HOME is set
107 MSVC_ANALYZE_FLAGS := $(if $(ENABLE_MSVC_ANALYZE),-analyze:ruleset$(SRCDIR)/solenv/vs/LibreOffice.ruleset,)
109 gb_FilterOutClangCFLAGS += $(MSVC_ANALYZE_FLAGS)
111 gb_CFLAGS := \
112 -utf-8 \
113 -Gd \
114 -GR \
115 -Gs \
116 -GS \
117 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
118 -nologo \
119 -W4 \
120 -wd4244 \
121 -wd4505 \
122 -bigobj \
124 gb_CXXFLAGS_DISABLE_WARNINGS = -w
126 gb_CXXFLAGS := \
127 -utf-8 \
128 $(CXXFLAGS_CXX11) \
129 -Gd \
130 -GR \
131 -Gs \
132 -GS \
133 -Gy \
134 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
135 -nologo \
136 -W4 \
137 -wd4127 \
138 -wd4201 \
139 -wd4244 \
140 -wd4250 \
141 -wd4251 \
142 -wd4267 \
143 -wd4275 \
144 -wd4505 \
145 -wd4611 \
146 -wd4706 \
147 -bigobj \
148 $(if $(ENABLE_DEBUG),$(MSVC_ANALYZE_FLAGS),) \
150 ifneq ($(COM_IS_CLANG),TRUE)
151 gb_CXXFLAGS += -Zc:inline
152 gb_CXXFLAGS_ZCINLINE_OFF := -Zc:inline-
153 endif
155 ifeq ($(CPUNAME),INTEL)
157 gb_CXXFLAGS += \
158 -Zm500 \
160 gb_CFLAGS += \
161 -Zm500 \
163 endif
165 ifeq ($(HAVE_DLLEXPORTINLINES),TRUE)
166 gb_CXXFLAGS += -Zc:dllexportInlines-
167 endif
169 gb_CXXFLAGS_include := -FI
170 ifeq ($(COM_IS_CLANG),TRUE)
171 gb_CXXFLAGS_no_pch_warnings := -Wno-clang-cl-pch
172 endif
174 ifneq ($(COM_IS_CLANG),TRUE)
176 # Work around MSVC 2017 C4702 compiler bug with release builds
177 # https://lists.freedesktop.org/archives/libreoffice/2018-July/080532.html
178 # https://lists.freedesktop.org/archives/libreoffice/2018-August/080776.html
179 gb_CXXFLAGS += \
180 $(if $(ENABLE_OPTIMIZED),-wd4702) \
182 endif
184 # rc.exe does not support -nologo in 6.1.6723.1 that is in the Windows SDK 6.0A
185 gb_RCFLAGS += -nologo
187 # C4005: 'identifier' : macro redefinition
189 gb_PCHWARNINGS = \
190 -we4650 \
191 -we4651 \
192 -we4652 \
193 -we4653 \
194 -we4005 \
196 gb_STDLIBS := \
197 advapi32.lib \
199 gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-WX)
201 # there does not seem to be a way to force C++03 with MSVC, nor with clang-cl against MSVC system
202 # headers; the oldest version that MSVC supports is C++14, so use that as a rather imperfect
203 # approximation:
204 gb_CXX03FLAGS := -std:c++14
206 gb_LinkTarget_EXCEPTIONFLAGS := \
207 -EHs \
209 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
211 ifneq ($(gb_ENABLE_PCH),)
212 ifeq ($(COM_IS_CLANG),TRUE)
213 # the same as in com_GCC_defs.mk
214 gb_NO_PCH_TIMESTAMP := -Xclang -fno-pch-timestamp
215 endif
216 endif
218 gb_LinkTarget_LDFLAGS := \
219 $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-nologo,) \
220 $(patsubst %,-LIBPATH:%,$(filter-out .,$(subst ;, ,$(subst \,/,$(ILIB))))) \
222 # Prevent warning spamming
223 # Happens because of the way we link our unit tests with our libraries.
224 # LNK4049: locally defined symbol
225 gb_LinkTarget_LDFLAGS += \
226 /ignore:4217 /ignore:4049
229 ifeq ($(ENABLE_Z7_DEBUG),)
230 gb_DEBUGINFO_FLAGS := \
231 -FS \
232 -Zi \
234 else
235 # ccache does not work with -Zi
236 gb_DEBUGINFO_FLAGS := \
237 -Z7 \
239 endif
241 # See gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO
242 gb_LINKER_DEBUGINFO_FLAGS :=
244 gb_COMPILEROPTFLAGS := -O2 -Oy-
245 gb_COMPILERNOOPTFLAGS := -Od
246 gb_COMPILERDEBUGOPTFLAGS :=
248 ifeq ($(gb_FULLDEPS),$(true))
249 gb_COMPILERDEPFLAGS := -showIncludes
250 define gb_create_deps
251 | $(GBUILDDIR)/platform/filter-showIncludes.awk -vdepfile=$(1) -vobjectfile=$(2) -vsourcefile=$(3); exit $${PIPESTATUS[0]}
252 endef
253 else
254 gb_COMPILERDEPFLAGS :=
255 define gb_create_deps
256 | $(GBUILDDIR)/platform/filter-sourceName.awk; exit $${PIPESTATUS[0]}
257 endef
258 endif
260 gb_LTOFLAGS := $(if $(filter TRUE,$(ENABLE_LTO)),-GL)
262 # VS2019 produces a warning C4857, that it doesn't support -std:c++20; it can't
263 # be suppressed by -wd4857, only by -Wv:18. The warning seems incorrect, because
264 # using -std:c++17 produces errors about undeclared 'char8_t'. VS2022 doesn't
265 # have the problem, so drop -Wv:18 when bumping baseline.
266 # Similarly, at least VS2022 Preview 17.12.0 Preview 2.1 with --with-latest-c++ emits a "warning
267 # C4857: C++/CLI mode does not support C++ versions newer than C++20; setting language to
268 # /std:c++20" that cannot be disabled by adding -wd4857, so hardcode a -std:c++20 substitution in
269 # that case:
270 gb_CXXCLRFLAGS := \
271 $(if $(COM_IS_CLANG), \
272 $(patsubst -std=%,-std:c++20 -Zc:__cplusplus,$(gb_CXXFLAGS)), \
273 $(if $(filter -std:c++latest,$(CXXFLAGS_CXX11)), \
274 $(patsubst -std:c++latest,-std:c++20,$(gb_CXXFLAGS)), \
275 $(gb_CXXFLAGS))) \
276 $(gb_LinkTarget_EXCEPTIONFLAGS) \
277 -AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
278 -EHa \
279 -clr \
280 $(if $(filter 16.0,$(VCVER)),-Wv:18) \
281 -Zc:twoPhase- \
284 ifeq ($(COM_IS_CLANG),TRUE)
286 gb_CFLAGS += \
287 -Wendif-labels \
288 -Wshadow \
289 -Wstrict-prototypes \
290 -Wundef \
291 -Wunused-macros \
293 gb_CXXFLAGS += \
294 -Wendif-labels \
295 -Wimplicit-fallthrough \
296 -Wno-missing-braces \
297 -Woverloaded-virtual \
298 -Wshadow \
299 -Wundef \
300 -Wunused-macros \
302 endif
304 ifeq ($(COM_IS_CLANG),TRUE)
305 gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
306 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.dll -Xclang -add-plugin -Xclang loplugin
307 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
308 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
309 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
310 endif
311 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
312 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
313 endif
314 gb_COMPILER_PLUGINS_TOOL := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.dll -Xclang -plugin -Xclang loplugin $(foreach plugin,$(COMPILER_PLUGIN_TOOL), -Xclang -plugin-arg-loplugin -Xclang $(plugin))
315 ifneq ($(UPDATE_FILES),)
316 gb_COMPILER_PLUGINS_TOOL += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
317 endif
318 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
319 gb_COMPILER_PLUGINS_TOOL += -Xclang -plugin-arg-loplugin -Xclang --debug
320 endif
321 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
322 -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
323 else
324 gb_COMPILER_TEST_FLAGS :=
325 gb_COMPILER_PLUGINS :=
326 gb_COMPILER_PLUGINS_TOOL :=
327 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
328 endif
330 # Helper class
332 gb_Helper_set_ld_path := $(call gb_Helper_cyg_path,PATH="$(INSTDIR_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER):$(INSTDIR_FOR_BUILD)/$(LIBO_BIN_FOLDER):$$PATH")
334 define gb_Helper_prepend_ld_path
335 PATH="$(call gb_Helper_cyg_path,$(INSTDIR_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER):$(INSTDIR_FOR_BUILD)/$(LIBO_BIN_FOLDER):$(1):$$PATH")
336 endef
338 # $(1): one directory pathname to append to the ld path
339 define gb_Helper_extend_ld_path
340 $(gb_Helper_set_ld_path)':$(call gb_Helper_cyg_path,$(1))'
341 endef
343 # common macros to build GPG related libraries
344 # we explicitly have to replace cygwin with mingw32 for the host, but the build must stay cygwin, or cmd.exe processes will be spawned
345 gb_WIN_GPG_WINDRES_target := $(if $(filter INTEL,$(CPUNAME)),pe-i386,pe-x86-64)
346 gb_WIN_GPG_platform_switches := --build=$(BUILD_PLATFORM) --host=$(subst cygwin,mingw32,$(HOST_PLATFORM))
347 gb_WIN_GPG_cross_setup_exports = export REAL_BUILD_CC="$(filter-out -%,$(CC_FOR_BUILD))" REAL_BUILD_CC_FLAGS="$(filter -%,$(CC_FOR_BUILD))" \
348 && export CC_FOR_BUILD="$(call gb_Executable_get_target_for_build,gcc-wrapper) --wrapper-env-prefix=REAL_BUILD_ $(SOLARINC) -L$(subst ;, -L,$(ILIB_FOR_BUILD))" \
349 && export RC='windres -O COFF --target=$(gb_WIN_GPG_WINDRES_target) --preprocessor=$(call gb_Executable_get_target_for_build,cpp) --preprocessor-arg=-+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)'
351 ifneq ($(gb_ENABLE_PCH),)
352 # Enable use of .sum files for PCHs.
353 gb_COMPILER_SETUP += CCACHE_PCH_EXTSUM=1
354 endif
356 # vim: set noet sw=4: