Skip to content

Commit fdca61a

Browse files
authored
aligned build options of Visual Studio project configurations and added them to CMake (#4020)
1 parent 1bf7b3b commit fdca61a

File tree

5 files changed

+124
-33
lines changed

5 files changed

+124
-33
lines changed

cli/cli.vcxproj

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
<BufferSecurityCheck>true</BufferSecurityCheck>
161161
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
162162
<Optimization>Disabled</Optimization>
163-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
163+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
164164
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
165165
<WarningLevel>Level4</WarningLevel>
166166
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4482;4512;4701;4706;4800;4805</DisableSpecificWarnings>
@@ -175,7 +175,7 @@
175175
<GenerateDebugInformation>true</GenerateDebugInformation>
176176
<SubSystem>Console</SubSystem>
177177
<SuppressStartupBanner>true</SuppressStartupBanner>
178-
<ProgramDatabaseFile>$(TargetDir)cli.pdb</ProgramDatabaseFile>
178+
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
179179
<LargeAddressAware>true</LargeAddressAware>
180180
<StackReserveSize>8000000</StackReserveSize>
181181
<StackCommitSize>8000000</StackCommitSize>
@@ -214,7 +214,7 @@
214214
<BufferSecurityCheck>true</BufferSecurityCheck>
215215
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
216216
<Optimization>Disabled</Optimization>
217-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
217+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
218218
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
219219
<WarningLevel>Level4</WarningLevel>
220220
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4482;4512;4701;4706;4800;4805</DisableSpecificWarnings>
@@ -231,6 +231,7 @@
231231
<SuppressStartupBanner>true</SuppressStartupBanner>
232232
<StackReserveSize>8000000</StackReserveSize>
233233
<StackCommitSize>8000000</StackCommitSize>
234+
<LargeAddressAware>true</LargeAddressAware>
234235
</Link>
235236
</ItemDefinitionGroup>
236237
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-PCRE|x64'">
@@ -256,14 +257,15 @@
256257
<SuppressStartupBanner>true</SuppressStartupBanner>
257258
<StackReserveSize>8000000</StackReserveSize>
258259
<StackCommitSize>8000000</StackCommitSize>
260+
<LargeAddressAware>true</LargeAddressAware>
259261
</Link>
260262
</ItemDefinitionGroup>
261263
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
262264
<ClCompile>
263265
<AdditionalIncludeDirectories>..\lib;..\externals;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
264266
<BufferSecurityCheck>false</BufferSecurityCheck>
265267
<Optimization>MaxSpeed</Optimization>
266-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
268+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
267269
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
268270
<WarningLevel>Level4</WarningLevel>
269271
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@@ -277,11 +279,12 @@
277279
<AdditionalOptions>/Zc:throwingNew /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
278280
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
279281
<LanguageStandard>stdcpp14</LanguageStandard>
282+
<FunctionLevelLinking>true</FunctionLevelLinking>
280283
</ClCompile>
281284
<Link>
282285
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
283286
<AdditionalLibraryDirectories>../externals;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
284-
<GenerateDebugInformation>false</GenerateDebugInformation>
287+
<GenerateDebugInformation>true</GenerateDebugInformation>
285288
<SubSystem>Console</SubSystem>
286289
<SuppressStartupBanner>true</SuppressStartupBanner>
287290
<OptimizeReferences>true</OptimizeReferences>
@@ -311,11 +314,12 @@
311314
<AdditionalOptions>/Zc:throwingNew /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
312315
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
313316
<LanguageStandard>stdcpp14</LanguageStandard>
317+
<FunctionLevelLinking>true</FunctionLevelLinking>
314318
</ClCompile>
315319
<Link>
316320
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
317321
<AdditionalLibraryDirectories>../externals;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
318-
<GenerateDebugInformation>false</GenerateDebugInformation>
322+
<GenerateDebugInformation>true</GenerateDebugInformation>
319323
<SubSystem>Console</SubSystem>
320324
<SuppressStartupBanner>true</SuppressStartupBanner>
321325
<OptimizeReferences>true</OptimizeReferences>
@@ -331,7 +335,7 @@
331335
<AdditionalIncludeDirectories>..\lib;..\externals;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
332336
<BufferSecurityCheck>false</BufferSecurityCheck>
333337
<Optimization>MaxSpeed</Optimization>
334-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
338+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
335339
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
336340
<WarningLevel>Level4</WarningLevel>
337341
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@@ -358,6 +362,7 @@
358362
<SetChecksum>true</SetChecksum>
359363
<StackReserveSize>8000000</StackReserveSize>
360364
<StackCommitSize>8000000</StackCommitSize>
365+
<LargeAddressAware>true</LargeAddressAware>
361366
</Link>
362367
</ItemDefinitionGroup>
363368
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-PCRE|x64'">
@@ -384,14 +389,15 @@
384389
<Link>
385390
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
386391
<AdditionalLibraryDirectories>../externals;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
387-
<GenerateDebugInformation>false</GenerateDebugInformation>
392+
<GenerateDebugInformation>true</GenerateDebugInformation>
388393
<SubSystem>Console</SubSystem>
389394
<SuppressStartupBanner>true</SuppressStartupBanner>
390395
<OptimizeReferences>true</OptimizeReferences>
391396
<EnableCOMDATFolding>true</EnableCOMDATFolding>
392397
<SetChecksum>true</SetChecksum>
393398
<StackReserveSize>8000000</StackReserveSize>
394399
<StackCommitSize>8000000</StackCommitSize>
400+
<LargeAddressAware>true</LargeAddressAware>
395401
</Link>
396402
</ItemDefinitionGroup>
397403
<ItemGroup>

cmake/compilerDefinitions.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ if (MSVC)
44
add_definitions(-DDEBUG)
55
endif()
66

7+
#add_definitions(-DCPPCHECKLIB_IMPORT)
8+
#add_definitions(-DTINYXML2_IMPORT)
9+
add_definitions(-DWIN32)
710
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
11+
add_definitions(-DWIN32_LEAN_MEAN)
12+
add_definitions(-D_WIN64)
813
endif()
914

1015
# TODO: this should probably apply to the compiler and not the platform

cmake/compileroptions.cmake

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,48 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
101101
endif()
102102

103103
if (MSVC)
104-
add_compile_options(/W4)
104+
# General
105+
add_compile_options(/W4) # Warning Level
106+
add_compile_options(/Zi) # Debug Information Format - Program Database
107+
if (WARNINGS_ARE_ERRORS)
108+
add_compile_options(/WX) # Treat Warning As Errors
109+
endif()
110+
add_compile_options(/MP) # Multi-processor Compilation
111+
112+
# Advanced
113+
# Character Set - Use Unicode Character Set
114+
# No Whole Program Optimization
115+
116+
# C/C++ - Optimization
117+
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
118+
add_compile_options(/O2) # Optimization - Maximum Optimization (Favor Speed)
119+
add_compile_options(/Ob2) # Inline Function Expansion - Any Suitable
120+
add_compile_options(/Oi) # Enable Intrinsic Functions
121+
add_compile_options(/Ot) # Favor fast code
122+
add_compile_options(/Oy) # Omit Frame Pointers
123+
else()
124+
add_compile_options(/Od) # Optimization - Disabled
125+
endif()
126+
127+
# C/C++ - Code Generation
128+
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
129+
add_compile_options(/GF) # Enable String Pooling
130+
add_compile_options(/MD) # Runtime Library - Multi-threaded DLL
131+
add_compile_options(/GS-) # Disable Security Check
132+
add_compile_options(/Gy) # Enable Function-Level Linking
133+
else()
134+
add_compile_options(/MDd) # Runtime Library - Multi-threaded Debug DLL
135+
add_compile_options(/GS) # Enable Security Check
136+
endif()
137+
138+
# C/C++ - Language
139+
add_compile_options(/Zc:rvalueCast) # Enforce type conversion rules
140+
add_compile_options(/std:c++14) # C++ Langage Standard - ISO C++14 Standard
141+
142+
# C/C++ - Browse Information
143+
# Enable Browse Information - No
144+
145+
# C/C++ - Advanced
105146
add_compile_options(/wd4018) # warning C4018: '>': signed/unsigned mismatch
106147
add_compile_options(/wd4127) # warning C4127: conditional expression is constant
107148
add_compile_options(/wd4146) # warning C4146: unary minus operator applied to unsigned type, result still unsigned
@@ -117,8 +158,31 @@ if (MSVC)
117158
add_compile_options(/wd4800) # warning C4800: 'const SymbolDatabase *' : forcing value to bool 'true' or 'false' (performance warning)
118159
add_compile_options(/wd4805) # warning C4805: '==' : unsafe mix of type 'bool' and type 'long long' in operation
119160

120-
if (WARNINGS_ARE_ERRORS)
121-
add_compile_options(/WX)
161+
# C/C++ - All Options
162+
add_compile_options(/Zc:throwingNew /Zc:__cplusplus) # Additional Options
163+
164+
# Linker - General
165+
if(CMAKE_BUILD_TYPE MATCHES "Debug")
166+
add_link_options(/INCREMENTAL) # Enable Incremental Linking - Yes
167+
endif()
168+
add_link_options(/NOLOGO) # SUppress Startup Banner - Yes
169+
# Ignore Import Library - Yes
170+
171+
# Linker - Debugging
172+
add_link_options(/DEBUG) # Generate Debug Information
173+
174+
# Linker - System
175+
# Stack Reserve Size - 8000000
176+
# Stack Commit Size - 8000000
177+
add_link_options(/LARGEADDRESSAWARE) # Enbale Large Addresses - Yes
178+
179+
# Linker - Optimization
180+
add_link_options(/OPT:REF) # References - Yes
181+
add_link_options(/OPT:ICF) # Enable COMDAT Folding - Yes
182+
183+
# Linker - Advanced
184+
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
185+
add_link_options(/RELEASE) # Set Checksum - Yes
122186
endif()
123187
endif()
124188

0 commit comments

Comments
 (0)