Bump version to 6.4.7.2.M8
[LibreOffice.git] / solenv / gbuild / platform / com_MSC_defs.mk
blob8ba47447df32b197f331c73464f13cf341a49097
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 # set tmpdir to some mixed case path, suitable for native tools
21 gb_TMPDIR:=$(if $(TMPDIR),$(shell cygpath -m $(TMPDIR)),$(shell cygpath -m /tmp))
23 # please make generic Windows modifications to windows.mk
24 include $(GBUILDDIR)/platform/windows.mk
26 gb_CC := cl
27 gb_CXX := cl
28 gb_LINK := link
29 gb_AWK := awk
30 gb_CLASSPATHSEP := ;
31 gb_RC := rc
32 gb_YACC := bison
34 # use CC/CXX if they are nondefaults
35 ifneq ($(origin CC),default)
36 gb_CC := $(CC)
37 gb_GCCP := $(CC)
38 endif
39 ifneq ($(origin CXX),default)
40 gb_CXX := $(CXX)
41 endif
43 # _SCL_SECURE_NO_WARNINGS avoids deprecation warnings for STL algorithms
44 # like std::copy, std::transform (when MSVC_USE_DEBUG_RUNTIME is enabled)
46 gb_COMPILERDEFS := \
47 -DBOOST_ERROR_CODE_HEADER_ONLY \
48 -DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE \
49 -DBOOST_SYSTEM_NO_DEPRECATED \
50 -D_HAS_AUTO_PTR_ETC \
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_CRT_NON_CONFORMING_SWPRINTFS \
55 -D_CRT_NONSTDC_NO_DEPRECATE \
56 -D_CRT_SECURE_NO_DEPRECATE \
57 -D_SCL_SECURE_NO_WARNINGS \
58 -D_MT \
59 -D_DLL \
60 -DCPPU_ENV=$(gb_CPPU_ENV) \
62 ifeq ($(CPUNAME),INTEL)
63 gb_COMPILERDEFS += \
64 -DBOOST_MEM_FN_ENABLE_CDECL \
66 endif
68 gb_RCDEFS := \
69 $(gb_WIN_VERSION_DEFS) \
71 gb_RCFLAGS :=
73 gb_AFLAGS := $(AFLAGS)
75 # Do we really need to disable this many warnings? It seems to me that
76 # many of these warnings are for constructs that we have been actively
77 # cleaning away from the code, to avoid warnings when building with
78 # gcc or Clang and -Wall -Werror.
80 # C4091: 'typedef ': ignored on left of '' when no variable is declared
82 # C4100: 'identifier' : unreferenced formal parameter
84 # C4127: conditional expression is constant
86 # C4189: 'identifier' : local variable is initialized but not referenced
88 # C4200: nonstandard extension used : zero-sized array in struct/union
90 # C4201: nonstandard extension used : nameless struct/union
92 # C4244: nonstandard extension used : formal parameter 'identifier'
93 # was previously defined as a type
95 # C4250: 'class1' : inherits 'class2::member' via dominance
97 # C4251: 'identifier' : class 'type' needs to have dll-interface to be
98 # used by clients of class 'type2'
100 # C4267: conversion from 'size_t' to 'type', possible loss of data
102 # C4275: non-DLL-interface classkey 'identifier' used as base for
103 # DLL-interface classkey 'identifier'
105 # C4290: C++ exception specification ignored except to indicate a
106 # function is not __declspec(nothrow)
108 # C4351: new behavior: elements of array 'array' will be default
109 # initialized
110 # (an issue with MSVC 2013 that appears to be gone with MSVC 2015)
112 # C4373: '%$S': virtual function overrides '%$pS', previous versions
113 # of the compiler did not override when parameters only differed by
114 # const/volatile qualifiers.
115 # [translation: ancient compilers that don't actually support C++ do
116 # stupid things]
118 # C4505: 'function' : unreferenced local function has been removed
120 # C4510: 'class' : default constructor could not be generated
122 # C4512: 'class' : assignment operator could not be generated
123 # (an issue with MSVC 2013 that appears to be gone with MSVC 2015)
125 # C4610: 'class' can never be instantiated - user defined constructor required
127 # C4611: interaction between 'function' and C++ object destruction is
128 # non-portable
130 # C4702: unreachable code
132 # C4706: assignment within conditional expression
134 # C4800: 'type' : forcing value to bool 'true' or 'false' (performance
135 # warning)
137 gb_CFLAGS := \
138 -utf-8 \
139 -Gd \
140 -GR \
141 -Gs \
142 -GS \
143 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
144 -nologo \
145 -W4 \
146 -wd4091 \
147 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4100) \
148 -wd4127 \
149 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4189) \
150 -wd4200 \
151 -wd4244 \
152 -wd4251 \
153 -wd4505 \
154 -wd4512 \
155 -wd4706 \
156 -wd4800 \
157 -wd4267 \
159 gb_CXXFLAGS_DISABLE_WARNINGS = -w
161 ifneq ($(COM_IS_CLANG),TRUE)
163 # clang-cl doesn't support -Wv:18 for now
164 gb_CFLAGS += \
165 -Wv:18 \
167 endif
169 gb_CXXFLAGS := \
170 -utf-8 \
171 $(CXXFLAGS_CXX11) \
172 -Gd \
173 -GR \
174 -Gs \
175 -GS \
176 -Gy \
177 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
178 -nologo \
179 -W4 \
180 -wd4091 \
181 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4100) \
182 -wd4127 \
183 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4189) \
184 -wd4201 \
185 -wd4244 \
186 -wd4250 \
187 -wd4251 \
188 -wd4267 \
189 -wd4275 \
190 -wd4290 \
191 -wd4351 \
192 -wd4373 \
193 -wd4505 \
194 -wd4510 \
195 -wd4512 \
196 -wd4610 \
197 -wd4611 \
198 -wd4706 \
199 -wd4800 \
201 ifeq ($(CPUNAME),INTEL)
203 gb_CXXFLAGS += \
204 -Zm500 \
206 gb_CFLAGS += \
207 -Zm500 \
209 endif
211 ifneq ($(COM_IS_CLANG),TRUE)
213 # clang-cl doesn't support -Wv:18 for now
214 # Work around MSVC 2017 C4702 compiler bug with release builds
215 # http://document-foundation-mail-archive.969070.n3.nabble.com/Windows-32-bit-build-failure-unreachable-code-tp4243848.html
216 # http://document-foundation-mail-archive.969070.n3.nabble.com/64-bit-Windows-build-failure-after-MSVC-Update-tp4246816.html
217 gb_CXXFLAGS += \
218 -Wv:18 \
219 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4702) \
221 endif
223 # rc.exe does not support -nologo in 6.1.6723.1 that is in the Windows SDK 6.0A
224 gb_RCFLAGS += -nologo
226 # C4005: 'identifier' : macro redefinition
228 gb_PCHWARNINGS = \
229 -we4650 \
230 -we4651 \
231 -we4652 \
232 -we4653 \
233 -we4005 \
235 gb_STDLIBS := \
236 advapi32.lib \
238 gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-WX)
240 # there does not seem to be a way to force C++03 with MSVC
241 gb_CXX03FLAGS :=
243 gb_LinkTarget_EXCEPTIONFLAGS := \
244 -DEXCEPTIONS_ON \
245 -EHs \
247 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
249 gb_LinkTarget_LDFLAGS := \
250 $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-nologo,) \
251 $(patsubst %,-LIBPATH:%,$(filter-out .,$(subst ;, ,$(subst \,/,$(ILIB))))) \
253 # Prevent warning spamming
254 # Happens because of the way we link our unit tests with our libraries.
255 # LNK4049: locally defined symbol
256 gb_LinkTarget_LDFLAGS += \
257 /ignore:4217 /ignore:4049
260 gb_DEBUGINFO_FLAGS := \
261 -FS \
262 -Zi \
264 # See gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO
265 gb_LINKER_DEBUGINFO_FLAGS :=
267 gb_COMPILEROPTFLAGS := -O2 -Oy-
268 gb_COMPILERNOOPTFLAGS := -Od
270 ifeq ($(gb_FULLDEPS),$(true))
271 gb_COMPILERDEPFLAGS := -showIncludes
272 define gb_create_deps
273 | LC_ALL=C $(GBUILDDIR)/platform/filter-showIncludes.awk -vdepfile=$(1) -vobjectfile=$(2) -vsourcefile=$(3); exit $${PIPESTATUS[0]}
274 endef
275 else
276 gb_COMPILERDEPFLAGS :=
277 define gb_create_deps
278 | LC_ALL=C $(GBUILDDIR)/platform/filter-sourceName.awk; exit $${PIPESTATUS[0]}
279 endef
280 endif
282 gb_LTOFLAGS := $(if $(filter TRUE,$(ENABLE_LTO)),-GL)
284 # When compiling for CLR, disable "warning C4339: use of undefined type detected
285 # in CLR meta-data - use of this type may lead to a runtime exception":
286 gb_CXXCLRFLAGS := \
287 $(if $(COM_IS_CLANG), \
288 $(patsubst -std=%,-std:c++17 -Zc:__cplusplus,$(gb_CXXFLAGS)), \
289 $(gb_CXXFLAGS)) \
290 $(gb_LinkTarget_EXCEPTIONFLAGS) \
291 -AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
292 -EHa \
293 -clr \
294 -wd4339 \
295 -Wv:18 \
296 -wd4267 \
298 ifeq ($(COM_IS_CLANG),TRUE)
300 gb_CFLAGS += \
301 -Wdeclaration-after-statement \
302 -Wendif-labels \
303 -Wshadow \
304 -Wstrict-prototypes \
305 -Wundef \
306 -Wunused-macros \
308 gb_CXXFLAGS += \
309 -Wendif-labels \
310 -Wimplicit-fallthrough \
311 -Wno-missing-braces \
312 -Wnon-virtual-dtor \
313 -Woverloaded-virtual \
314 -Wshadow \
315 -Wundef \
316 -Wunused-macros \
318 endif
320 ifeq ($(COM_IS_CLANG),TRUE)
321 gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
322 ifeq ($(COMPILER_PLUGIN_TOOL),)
323 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.dll -Xclang -add-plugin -Xclang loplugin
324 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
325 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
326 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
327 endif
328 else
329 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.dll -Xclang -plugin -Xclang loplugin $(foreach plugin,$(COMPILER_PLUGIN_TOOL), -Xclang -plugin-arg-loplugin -Xclang $(plugin))
330 ifneq ($(UPDATE_FILES),)
331 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
332 endif
333 endif
334 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
335 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
336 endif
337 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
338 -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
339 else
340 gb_COMPILER_TEST_FLAGS :=
341 gb_COMPILER_PLUGINS :=
342 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
343 endif
345 # Helper class
347 ifeq ($(GNUMAKE_WIN_NATIVE),TRUE)
348 gb_Helper_set_ld_path := PATH="$(shell cygpath -w $(INSTDIR)/$(LIBO_URE_LIB_FOLDER));$(shell cygpath -w $(INSTDIR)/$(LIBO_BIN_FOLDER));$$PATH"
350 define gb_Helper_prepend_ld_path
351 PATH="$(shell cygpath -w $(INSTDIR)/$(LIBO_URE_LIB_FOLDER));$(shell cygpath -w $(INSTDIR)/$(LIBO_BIN_FOLDER));$(1);$$PATH"
352 endef
354 # $(1): one directory pathname to append to the ld path
355 define gb_Helper_extend_ld_path
356 $(gb_Helper_set_ld_path)';$(shell cygpath -w $(1))'
357 endef
359 else
360 gb_Helper_set_ld_path := PATH="$(shell cygpath -u $(INSTDIR)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR)/$(LIBO_BIN_FOLDER)):$$PATH"
362 define gb_Helper_prepend_ld_path
363 PATH="$(shell cygpath -u $(INSTDIR)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR)/$(LIBO_BIN_FOLDER)):$(1):$$PATH"
364 endef
366 # $(1): one directory pathname to append to the ld path
367 define gb_Helper_extend_ld_path
368 $(gb_Helper_set_ld_path):$(shell cygpath -u $(1))
369 endef
371 endif
373 # vim: set noet sw=4: