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,17 +28,13 @@ 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-
3831if (PLATFORM EQUAL 64)
3932 # This definition is necessary to work around a bug with Intellisense described
4033 # here: http://tinyurl.com/2cb428. Syntax highlighting is important for proper
4134 # debugger functionality.
4235 target_compile_definitions (trinity-compile-option-interface
4336 INTERFACE
44- -D_WIN64 )
37+ _WIN64 )
4538
4639 message (STATUS "MSVC: 64-bit platform, enforced -D_WIN64 parameter" )
4740
@@ -59,24 +52,19 @@ else()
5952 message (STATUS "MSVC: Disabled Safe Exception Handlers for debug builds" )
6053endif ()
6154
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
6455if ("${CMAKE_MAKE_PROGRAM} " MATCHES "MSBuild" )
65- target_compile_definitions (trinity-compile-option-interface
56+ # multithreaded compiling on VS
57+ target_compile_options (trinity-compile-option-interface
6658 INTERFACE
67- -D_BUILD_DIRECTIVE= "$(ConfigurationName)" )
59+ /MP )
6860else ()
69- # while all make-like generators do (nmake, ninja)
70- target_compile_definitions (trinity-compile-option-interface
61+ # Forces writes to the PDB file to be serialized through mspdbsrv.exe (/FS)
62+ # Enable faster PDB generation in parallel builds by minimizing RPC calls to mspdbsrv.exe (/Zf)
63+ target_compile_options (trinity-compile-option-interface
7164 INTERFACE
72- -D_BUILD_DIRECTIVE= "$< CONFIG>" )
65+ $<$< CONFIG:Debug,RelWithDebInfo>:/FS /Zf> )
7366endif ()
7467
75- # multithreaded compiling on VS
76- target_compile_options (trinity-compile-option-interface
77- INTERFACE
78- /MP)
79-
8068if ((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0) OR BUILD_SHARED_LIBS )
8169 # Enable extended object support
8270 target_compile_options (trinity-compile-option-interface
@@ -86,36 +74,38 @@ if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.2302
8674 message (STATUS "MSVC: Enabled increased number of sections in object files" )
8775endif ()
8876
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)
77+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
78+ # /Zc:throwingNew.
79+ # When you specify Zc:throwingNew on the command line, it instructs the compiler to assume
80+ # that the program will eventually be linked with a conforming operator new implementation,
81+ # and can omit all of these extra null checks from your program.
82+ # http://blogs.msdn.com/b/vcblog/archive/2015/08/06/new-in-vs-2015-zc-throwingnew.aspx
83+ target_compile_options (trinity-compile-option-interface
84+ INTERFACE
85+ /Zc:throwingNew)
86+ endif ()
9787
9888# Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns
9989target_compile_definitions (trinity-compile-option-interface
10090 INTERFACE
101- -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES )
91+ _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES )
10292message (STATUS "MSVC: Overloaded standard names" )
10393
10494# Ignore warnings about older, less secure functions
10595target_compile_definitions (trinity-compile-option-interface
10696 INTERFACE
107- -D_CRT_SECURE_NO_WARNINGS )
97+ _CRT_SECURE_NO_WARNINGS )
10898message (STATUS "MSVC: Disabled NON-SECURE warnings" )
10999
110100# Ignore warnings about POSIX deprecation
111101target_compile_definitions (trinity-compile-option-interface
112102 INTERFACE
113- -D_CRT_NONSTDC_NO_WARNINGS )
103+ _CRT_NONSTDC_NO_WARNINGS )
114104
115105# Force math constants like M_PI to be available
116106target_compile_definitions (trinity-compile-option-interface
117107 INTERFACE
118- -D_USE_MATH_DEFINES )
108+ _USE_MATH_DEFINES )
119109
120110message (STATUS "MSVC: Disabled POSIX warnings" )
121111
@@ -167,8 +157,8 @@ target_compile_options(trinity-compile-option-interface
167157if (ASAN)
168158 target_compile_definitions (trinity-compile-option-interface
169159 INTERFACE
170- -D_DISABLE_STRING_ANNOTATION
171- -D_DISABLE_VECTOR_ANNOTATION )
160+ _DISABLE_STRING_ANNOTATION
161+ _DISABLE_VECTOR_ANNOTATION )
172162
173163 target_compile_options (trinity-compile-option-interface
174164 INTERFACE
0 commit comments