bump product version to 7.6.3.2-android
[LibreOffice.git] / solenv / gbuild / platform / com_MSC_defs.mk
blobad425e9b5fdd564b625fb1f456cd5992745931fd
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_DUMPBIN := dumpbin
30 gb_AWK := awk
31 gb_CLASSPATHSEP := ;
32 gb_RC := rc
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_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING \
51 -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING \
52 -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING \
53 -D_CRT_NON_CONFORMING_SWPRINTFS \
54 -D_CRT_NONSTDC_NO_DEPRECATE \
55 -D_CRT_SECURE_NO_DEPRECATE \
56 -D_SCL_SECURE_NO_WARNINGS \
57 -D_MT \
58 -D_DLL \
59 -DCPPU_ENV=$(CPPU_ENV) \
61 ifeq ($(CPUNAME),INTEL)
62 gb_COMPILERDEFS += \
63 -DBOOST_MEM_FN_ENABLE_CDECL \
65 endif
67 gb_RCDEFS := \
68 $(gb_WIN_VERSION_DEFS) \
70 gb_RCFLAGS :=
72 gb_AFLAGS := $(AFLAGS)
74 # Do we really need to disable this many warnings? It seems to me that
75 # many of these warnings are for constructs that we have been actively
76 # cleaning away from the code, to avoid warnings when building with
77 # gcc or Clang and -Wall -Werror.
79 # C4127: conditional expression is constant
81 # C4201: nonstandard extension used : nameless struct/union
83 # C4244: nonstandard extension used : formal parameter 'identifier'
84 # was previously defined as a type
86 # C4250: 'class1' : inherits 'class2::member' via dominance
88 # C4251: 'identifier' : class 'type' needs to have dll-interface to be
89 # used by clients of class 'type2'
91 # C4267: conversion from 'size_t' to 'type', possible loss of data
93 # C4275: non-DLL-interface classkey 'identifier' used as base for
94 # DLL-interface classkey 'identifier'
96 # C4505: 'function' : unreferenced local function has been removed
98 # C4611: interaction between 'function' and C++ object destruction is
99 # non-portable
101 # C4702: unreachable code
103 # C4706: assignment within conditional expression
105 gb_CFLAGS := \
106 -utf-8 \
107 -Gd \
108 -GR \
109 -Gs \
110 -GS \
111 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
112 -nologo \
113 -W4 \
114 -wd4244 \
115 -wd4505 \
116 -bigobj \
118 gb_CXXFLAGS_DISABLE_WARNINGS = -w
120 ifneq ($(COM_IS_CLANG),TRUE)
122 # clang-cl doesn't support -Wv:18 for now
123 gb_CFLAGS += \
124 -Wv:18 \
126 endif
128 gb_CXXFLAGS := \
129 -utf-8 \
130 $(CXXFLAGS_CXX11) \
131 -Gd \
132 -GR \
133 -Gs \
134 -GS \
135 -Gy \
136 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
137 -nologo \
138 -W4 \
139 -wd4127 \
140 -wd4201 \
141 -wd4244 \
142 -wd4250 \
143 -wd4251 \
144 -wd4267 \
145 -wd4275 \
146 -wd4505 \
147 -wd4611 \
148 -wd4706 \
149 -bigobj \
151 ifneq ($(COM_IS_CLANG),TRUE)
152 gb_CXXFLAGS += -Zc:inline
153 gb_CXXFLAGS_ZCINLINE_OFF := -Zc:inline-
154 endif
156 ifeq ($(CPUNAME),INTEL)
158 gb_CXXFLAGS += \
159 -Zm500 \
161 gb_CFLAGS += \
162 -Zm500 \
164 endif
166 ifeq ($(HAVE_DLLEXPORTINLINES),TRUE)
167 gb_CXXFLAGS += -Zc:dllexportInlines-
168 endif
170 gb_CXXFLAGS_include := -FI
171 ifeq ($(COM_IS_CLANG),TRUE)
172 gb_CXXFLAGS_no_pch_warnings := -Wno-clang-cl-pch
173 endif
175 ifneq ($(COM_IS_CLANG),TRUE)
177 # clang-cl doesn't support -Wv:18 for now
178 # Work around MSVC 2017 C4702 compiler bug with release builds
179 # http://document-foundation-mail-archive.969070.n3.nabble.com/Windows-32-bit-build-failure-unreachable-code-tp4243848.html
180 # http://document-foundation-mail-archive.969070.n3.nabble.com/64-bit-Windows-build-failure-after-MSVC-Update-tp4246816.html
181 gb_CXXFLAGS += \
182 -Wv:18 \
183 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4702) \
185 endif
187 # rc.exe does not support -nologo in 6.1.6723.1 that is in the Windows SDK 6.0A
188 gb_RCFLAGS += -nologo
190 # C4005: 'identifier' : macro redefinition
192 gb_PCHWARNINGS = \
193 -we4650 \
194 -we4651 \
195 -we4652 \
196 -we4653 \
197 -we4005 \
199 gb_STDLIBS := \
200 advapi32.lib \
202 gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-WX)
204 # there does not seem to be a way to force C++03 with MSVC, nor with clang-cl against MSVC system
205 # headers
206 gb_CXX03FLAGS :=
208 gb_LinkTarget_EXCEPTIONFLAGS := \
209 -EHs \
211 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
213 ifneq ($(gb_ENABLE_PCH),)
214 ifeq ($(COM_IS_CLANG),TRUE)
215 # the same as in com_GCC_defs.mk
216 gb_NO_PCH_TIMESTAMP := -Xclang -fno-pch-timestamp
217 endif
218 endif
220 gb_LinkTarget_LDFLAGS := \
221 $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-nologo,) \
222 $(patsubst %,-LIBPATH:%,$(filter-out .,$(subst ;, ,$(subst \,/,$(ILIB))))) \
224 # Prevent warning spamming
225 # Happens because of the way we link our unit tests with our libraries.
226 # LNK4049: locally defined symbol
227 gb_LinkTarget_LDFLAGS += \
228 /ignore:4217 /ignore:4049
231 ifeq ($(ENABLE_Z7_DEBUG),)
232 gb_DEBUGINFO_FLAGS := \
233 -FS \
234 -Zi \
236 else
237 # ccache does not work with -Zi
238 gb_DEBUGINFO_FLAGS := \
239 -Z7 \
241 endif
243 # See gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO
244 gb_LINKER_DEBUGINFO_FLAGS :=
246 gb_COMPILEROPTFLAGS := -O2 -Oy-
247 gb_COMPILERNOOPTFLAGS := -Od
248 gb_COMPILERDEBUGOPTFLAGS :=
250 ifeq ($(gb_FULLDEPS),$(true))
251 gb_COMPILERDEPFLAGS := -showIncludes
252 define gb_create_deps
253 | $(GBUILDDIR)/platform/filter-showIncludes.awk -vdepfile=$(1) -vobjectfile=$(2) -vsourcefile=$(3); exit $${PIPESTATUS[0]}
254 endef
255 else
256 gb_COMPILERDEPFLAGS :=
257 define gb_create_deps
258 | $(GBUILDDIR)/platform/filter-sourceName.awk; exit $${PIPESTATUS[0]}
259 endef
260 endif
262 gb_LTOFLAGS := $(if $(filter TRUE,$(ENABLE_LTO)),-GL)
264 # When compiling for CLR, disable "warning C4339: use of undefined type detected
265 # in CLR meta-data - use of this type may lead to a runtime exception":
266 gb_CXXCLRFLAGS := \
267 $(if $(COM_IS_CLANG), \
268 $(patsubst -std=%,-std:c++17 -Zc:__cplusplus,$(gb_CXXFLAGS)), \
269 $(gb_CXXFLAGS)) \
270 $(gb_LinkTarget_EXCEPTIONFLAGS) \
271 -AI $(INSTDIR)/$(LIBO_URE_LIB_FOLDER) \
272 -EHa \
273 -clr \
274 -wd4339 \
275 -Wv:18 \
276 -wd4267 \
277 -Zc:twoPhase- \
279 ifeq ($(COM_IS_CLANG),TRUE)
281 gb_CFLAGS += \
282 -Wendif-labels \
283 -Wshadow \
284 -Wstrict-prototypes \
285 -Wundef \
286 -Wunused-macros \
288 gb_CXXFLAGS += \
289 -Wendif-labels \
290 -Wimplicit-fallthrough \
291 -Wno-missing-braces \
292 -Woverloaded-virtual \
293 -Wshadow \
294 -Wundef \
295 -Wunused-macros \
297 endif
299 ifeq ($(COM_IS_CLANG),TRUE)
300 gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
301 ifeq ($(COMPILER_PLUGIN_TOOL),)
302 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.dll -Xclang -add-plugin -Xclang loplugin
303 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
304 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
305 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
306 endif
307 else
308 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))
309 ifneq ($(UPDATE_FILES),)
310 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
311 endif
312 endif
313 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
314 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
315 endif
316 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
317 -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
318 else
319 gb_COMPILER_TEST_FLAGS :=
320 gb_COMPILER_PLUGINS :=
321 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
322 endif
324 # Helper class
326 gb_Helper_set_ld_path := PATH="$(shell cygpath -u $(INSTDIR_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR_FOR_BUILD)/$(LIBO_BIN_FOLDER)):$$PATH"
328 define gb_Helper_prepend_ld_path
329 PATH="$(shell cygpath -u $(INSTDIR_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR_FOR_BUILD)/$(LIBO_BIN_FOLDER)):$(1):$$PATH"
330 endef
332 # $(1): one directory pathname to append to the ld path
333 define gb_Helper_extend_ld_path
334 $(gb_Helper_set_ld_path)':$(shell cygpath -u $(1))'
335 endef
337 # common macros to build GPG related libraries
338 # we explicitly have to replace cygwin with mingw32 for the host, but the build must stay cygwin, or cmd.exe processes will be spawned
339 gb_WIN_GPG_WINDRES_target := $(if $(filter INTEL,$(CPUNAME)),pe-i386,pe-x86-64)
340 gb_WIN_GPG_platform_switches := --build=$(BUILD_PLATFORM) --host=$(subst cygwin,mingw32,$(HOST_PLATFORM))
341 gb_WIN_GPG_cross_setup_exports = export REAL_BUILD_CC="$(filter-out -%,$(CC_FOR_BUILD))" REAL_BUILD_CC_FLAGS="$(filter -%,$(CC_FOR_BUILD))" \
342 && 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))" \
343 && 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)'
345 ifneq ($(gb_ENABLE_PCH),)
346 # Enable use of .sum files for PCHs.
347 gb_COMPILER_SETUP += CCACHE_PCH_EXTSUM=1
348 endif
350 # vim: set noet sw=4: