Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / platform / com_MSC_defs.mk
blobaa82a93973d4b7b4fc011b3c502951bfb0f5f97c
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_CRT_NON_CONFORMING_SWPRINTFS \
51 -D_CRT_NONSTDC_NO_DEPRECATE \
52 -D_CRT_SECURE_NO_DEPRECATE \
53 -D_SCL_SECURE_NO_WARNINGS \
54 -D_MT \
55 -D_DLL \
56 -DCPPU_ENV=$(gb_CPPU_ENV) \
57 $(if $(findstring 120_70,$(VCVER)_$(WINDOWS_SDK_VERSION)),-D_USING_V110_SDK71_) \
59 ifeq ($(CPUNAME),INTEL)
60 gb_COMPILERDEFS += \
61 -DBOOST_MEM_FN_ENABLE_CDECL \
63 endif
65 gb_RCDEFS := \
66 -DWINVER=0x0502 \
67 -DWIN32 \
69 gb_RCFLAGS :=
71 gb_AFLAGS := $(AFLAGS)
73 # Do we really need to disable this many warnings? It seems to me that
74 # many of these warnings are for constructs that we have been actively
75 # cleaning away from the code, to avoid warnings when building with
76 # gcc or Clang and -Wall -Werror.
78 # C4100: 'identifier' : unreferenced formal parameter
80 # C4127: conditional expression is constant
82 # C4189: 'identifier' : local variable is initialized but not referenced
84 # C4201: nonstandard extension used : nameless struct/union
86 # C4242: 'identifier' : conversion from 'type1' to 'type2', possible
87 # loss of data
89 # C4244: nonstandard extension used : formal parameter 'identifier'
90 # was previously defined as a type
92 # C4250: 'class1' : inherits 'class2::member' via dominance
94 # C4251: 'identifier' : class 'type' needs to have dll-interface to be
95 # used by clients of class 'type2'
97 # C4267: conversion from 'size_t' to 'type', possible loss of data
99 # C4275: non-DLL-interface classkey 'identifier' used as base for
100 # DLL-interface classkey 'identifier'
102 # C4290: C++ exception specification ignored except to indicate a
103 # function is not __declspec(nothrow)
105 # C4351: new behavior: elements of array 'array' will be default
106 # initialized
108 # C4355: 'this' : used in base member initializer list
110 # C4373: '%$S': virtual function overrides '%$pS', previous versions
111 # of the compiler did not override when parameters only differed by
112 # const/volatile qualifiers.
113 # [translation: ancient compilers that don't actually support C++ do
114 # stupid things]
116 # C4481: nonstandard extension used: override specifier 'override'
117 # (MSVC 2010 warns about this, even though it's C++11 keyword)
119 # C4505: 'function' : unreferenced local function has been removed
121 # C4512: 'class' : assignment operator could not be generated
123 # C4611: interaction between 'function' and C++ object destruction is
124 # non-portable
126 # C4626: 'derived class' : assignment operator could not be generated
127 # because a base class assignment operator is inaccessible
129 # C4702: unreachable code
131 # C4706: assignment within conditional expression
133 # C4800: 'type' : forcing value to bool 'true' or 'false' (performance
134 # warning)
136 # C4913: user defined binary operator ',' exists but no overload could
137 # convert all operands, default built-in binary operator ',' used
139 gb_CFLAGS := \
140 -Gd \
141 -GR \
142 -Gs \
143 -GS \
144 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
145 -nologo \
146 -W4 \
147 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4100) \
148 -wd4127 \
149 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4189) \
150 -wd4242 \
151 -wd4244 \
152 -wd4251 \
153 -wd4355 \
154 -wd4505 \
155 -wd4512 \
156 -wd4626 \
157 -wd4706 \
158 -wd4800 \
159 -Zc:wchar_t- \
161 gb_CXXFLAGS := \
162 -Gd \
163 -GR \
164 -Gs \
165 -GS \
166 -Gy \
167 $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
168 -nologo \
169 -W4 \
170 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4100) \
171 -wd4127 \
172 $(if $(filter 0,$(gb_DEBUGLEVEL)),-wd4189) \
173 -wd4201 \
174 -wd4244 \
175 -wd4250 \
176 -wd4251 \
177 -wd4275 \
178 -wd4290 \
179 -wd4351 \
180 -wd4355 \
181 -wd4373 \
182 -wd4481 \
183 -wd4505 \
184 -wd4512 \
185 -wd4611 \
186 -wd4706 \
187 -wd4800 \
188 -wd4913 \
189 -Zc:wchar_t- \
192 ifneq ($(ENABLE_LTO),)
194 # Sigh, but there are cases of C4702 when using link-time code
195 # generation and optimization where I couldn't get
196 # __pragma(warning(disable:4702)) to help. Especially, the
197 # ImplInheritanceHelper2() {} in <cppuhelper/implbase2.hxx>
198 # was reported as containing "unreachable code" when linking
199 # the dbaccess dbu library. Let's try globally disabling C4702.
201 # Might be fixed in VS2013 though?
202 # VCVER=110 for VS2012
204 ifneq ($(filter 110,$(VCVER)),)
205 gb_CXXFLAGS += \
206 -wd4702 \
208 endif
210 endif
212 ifeq ($(CPUNAME),X86_64)
214 gb_CXXFLAGS += \
215 -wd4267 \
217 else
219 gb_CXXFLAGS += \
220 -Zm500 \
222 gb_CFLAGS += \
223 -Zm500 \
225 endif
227 # rc.exe does not support -nologo in 6.1.6723.1 that is in the Windows SDK 6.0A
228 gb_RCFLAGS += -nologo
230 # C4005: 'identifier' : macro redefinition
232 gb_PCHWARNINGS = \
233 -we4650 \
234 -we4651 \
235 -we4652 \
236 -we4653 \
237 -we4005 \
239 gb_STDLIBS := \
240 advapi32.lib \
242 gb_CFLAGS_WERROR := $(if $(ENABLE_WERROR),-WX)
244 # there does not seem to be a way to force C++03 with MSVC
245 gb_CXX03FLAGS :=
247 gb_LinkTarget_EXCEPTIONFLAGS := \
248 -DEXCEPTIONS_ON \
249 -EHa \
251 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
253 gb_LinkTarget_LDFLAGS := \
254 $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-nologo,) \
255 $(patsubst %,-LIBPATH:%,$(filter-out .,$(subst ;, ,$(subst \,/,$(ILIB))))) \
257 gb_DEBUG_CFLAGS := -Zi
259 ifeq ($(VCVER),120)
260 # Use -FS with VS2013: "Force Synchronous PDB Writes. Forces writes to
261 # the program database (PDB) file--created by /Zi or /ZI--to be
262 # serialized through MSPDBSRV.EXE"
263 gb_DEBUG_CFLAGS+=-FS
264 endif
266 # this does not use CFLAGS so it is not overridable
267 ifeq ($(gb_SYMBOL),$(true))
268 gb_CFLAGS+=$(gb_DEBUG_CFLAGS)
269 gb_CXXFLAGS+=$(gb_DEBUG_CFLAGS)
270 endif
272 gb_COMPILEROPTFLAGS := -O2 -Oy-
273 gb_COMPILERNOOPTFLAGS := -Od
275 ifeq ($(gb_FULLDEPS),$(true))
276 gb_COMPILERDEPFLAGS := -showIncludes
277 define gb_create_deps
278 | $(GBUILDDIR)/platform/filter-showIncludes.awk -vdepfile=$(1) -vobjectfile=$(2) -vsourcefile=$(3); exit $${PIPESTATUS[0]}
279 endef
280 else
281 gb_COMPILERDEPFLAGS :=
282 define gb_create_deps
283 endef
284 endif
286 gb_LTOFLAGS := $(if $(filter TRUE,$(ENABLE_LTO)),-GL)
288 # Helper class
290 ifeq ($(GNUMAKE_WIN_NATIVE),TRUE)
291 gb_Helper_set_ld_path := PATH="$(shell cygpath -w $(INSTDIR)/$(LIBO_URE_LIB_FOLDER));$(shell cygpath -w $(INSTDIR)/$(LIBO_BIN_FOLDER));$$PATH"
293 define gb_Helper_prepend_ld_path
294 PATH="$(shell cygpath -w $(INSTDIR)/$(LIBO_URE_LIB_FOLDER));$(shell cygpath -w $(INSTDIR)/$(LIBO_BIN_FOLDER));$(1);$$PATH"
295 endef
297 else
298 gb_Helper_set_ld_path := PATH="$(shell cygpath -u $(INSTDIR)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR)/$(LIBO_BIN_FOLDER)):$$PATH"
300 define gb_Helper_prepend_ld_path
301 PATH="$(shell cygpath -u $(INSTDIR)/$(LIBO_URE_LIB_FOLDER)):$(shell cygpath -u $(INSTDIR)/$(LIBO_BIN_FOLDER)):$(1):$$PATH"
302 endef
304 endif
306 # vim: set noet sw=4: