1- # set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
2- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin)
3-
41set (MSVC_EXPECTED_VERSION 19.32)
52set (MSVC_EXPECTED_VERSION_STRING "Microsoft Visual Studio 2022 17.2" )
63
@@ -31,21 +28,7 @@ target_compile_options(trinity-compile-option-interface
3128 INTERFACE
3229 /permissive-)
3330
34- # set up output paths ofr static libraries etc (commented out - shown here as an example only)
35- #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
36- #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
37-
38- if (PLATFORM EQUAL 64)
39- # This definition is necessary to work around a bug with Intellisense described
40- # here: http://tinyurl.com/2cb428. Syntax highlighting is important for proper
41- # debugger functionality.
42- target_compile_definitions (trinity-compile-option-interface
43- INTERFACE
44- -D_WIN64)
45-
46- message (STATUS "MSVC: 64-bit platform, enforced -D_WIN64 parameter" )
47-
48- else ()
31+ if (PLATFORM EQUAL 32)
4932 # mark 32 bit executables large address aware so they can use > 2GB address space
5033 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE" )
5134 message (STATUS "MSVC: Enabled large address awareness" )
@@ -59,24 +42,19 @@ else()
5942 message (STATUS "MSVC: Disabled Safe Exception Handlers for debug builds" )
6043endif ()
6144
62- # Set build-directive (used in core to tell which buildtype we used)
63- # msbuild/devenv don't set CMAKE_MAKE_PROGRAM, you can choose build type from a dropdown after generating projects
6445if ("${CMAKE_MAKE_PROGRAM} " MATCHES "MSBuild" )
65- target_compile_definitions (trinity-compile-option-interface
46+ # multithreaded compiling on VS
47+ target_compile_options (trinity-compile-option-interface
6648 INTERFACE
67- -D_BUILD_DIRECTIVE= "$(ConfigurationName)" )
49+ /MP )
6850else ()
69- # while all make-like generators do (nmake, ninja)
70- target_compile_definitions (trinity-compile-option-interface
51+ # Forces writes to the PDB file to be serialized through mspdbsrv.exe (/FS)
52+ # Enable faster PDB generation in parallel builds by minimizing RPC calls to mspdbsrv.exe (/Zf)
53+ target_compile_options (trinity-compile-option-interface
7154 INTERFACE
72- -D_BUILD_DIRECTIVE= "$< CONFIG>" )
55+ $<$< CONFIG:Debug,RelWithDebInfo>:/FS /Zf> )
7356endif ()
7457
75- # multithreaded compiling on VS
76- target_compile_options (trinity-compile-option-interface
77- INTERFACE
78- /MP)
79-
8058if ((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0) OR BUILD_SHARED_LIBS )
8159 # Enable extended object support
8260 target_compile_options (trinity-compile-option-interface
@@ -86,36 +64,36 @@ if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.2302
8664 message (STATUS "MSVC: Enabled increased number of sections in object files" )
8765endif ()
8866
89- # /Zc:throwingNew.
90- # When you specify Zc:throwingNew on the command line, it instructs the compiler to assume
91- # that the program will eventually be linked with a conforming operator new implementation,
92- # and can omit all of these extra null checks from your program.
93- # http://blogs.msdn.com/b/vcblog/archive/2015/08/06/new-in-vs-2015-zc-throwingnew.aspx
94- target_compile_options (trinity-compile-option- interface
95- INTERFACE
96- /Zc:throwingNew )
67+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
68+ target_compile_options (trinity-compile-option- interface
69+ INTERFACE
70+ /Zc:__cplusplus # Enable updated __cplusplus macro value
71+ /Zc:preprocessor # Enable preprocessor conformance mode
72+ /Zc:templateScope # Check template parameter shadowing
73+ /Zc:throwingNew) # Assume operator new throws
74+ endif ( )
9775
9876# Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns
9977target_compile_definitions (trinity-compile-option-interface
10078 INTERFACE
101- -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES )
79+ _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES )
10280message (STATUS "MSVC: Overloaded standard names" )
10381
10482# Ignore warnings about older, less secure functions
10583target_compile_definitions (trinity-compile-option-interface
10684 INTERFACE
107- -D_CRT_SECURE_NO_WARNINGS )
85+ _CRT_SECURE_NO_WARNINGS )
10886message (STATUS "MSVC: Disabled NON-SECURE warnings" )
10987
11088# Ignore warnings about POSIX deprecation
11189target_compile_definitions (trinity-compile-option-interface
11290 INTERFACE
113- -D_CRT_NONSTDC_NO_WARNINGS )
91+ _CRT_NONSTDC_NO_WARNINGS )
11492
11593# Force math constants like M_PI to be available
11694target_compile_definitions (trinity-compile-option-interface
11795 INTERFACE
118- -D_USE_MATH_DEFINES )
96+ _USE_MATH_DEFINES )
11997
12098message (STATUS "MSVC: Disabled POSIX warnings" )
12199
@@ -147,14 +125,15 @@ if(BUILD_SHARED_LIBS)
147125 message (STATUS "MSVC: Enabled shared linking" )
148126endif ()
149127
150- # Move some warnings that are enabled for other compilers from level 4 to level 3
128+ # Move some warnings that are enabled for other compilers from level 4 to level 3 and enable some warnings which are off by default
151129target_compile_options (trinity-compile-option-interface
152130 INTERFACE
153- /w34100 # C4100 'identifier' : unreferenced formal parameter
131+ /w15038 # C5038: data member 'member1' will be initialized after data member 'member2'
132+ /w34100 # C4100: 'identifier' : unreferenced formal parameter
154133 /w34101 # C4101: 'identifier' : unreferenced local variable
155134 /w34189 # C4189: 'identifier' : local variable is initialized but not referenced
156135 /w34389 # C4389: 'equality-operator' : signed/unsigned mismatch
157- /w35054) # C5054: 'operator 'operator-name': deprecated between enumerations of different types'
136+ /w35054) # C5054: 'operator 'operator-name': deprecated between enumerations of different types'
158137
159138# Enable and treat as errors the following warnings to easily detect virtual function signature failures:
160139# 'function' : member function does not override any base class virtual member function
@@ -167,8 +146,8 @@ target_compile_options(trinity-compile-option-interface
167146if (ASAN)
168147 target_compile_definitions (trinity-compile-option-interface
169148 INTERFACE
170- -D_DISABLE_STRING_ANNOTATION
171- -D_DISABLE_VECTOR_ANNOTATION )
149+ _DISABLE_STRING_ANNOTATION
150+ _DISABLE_VECTOR_ANNOTATION )
172151
173152 target_compile_options (trinity-compile-option-interface
174153 INTERFACE
0 commit comments