1
1
# CMakeList.txt : CMake project for modern_win32, include source and define
2
2
# project specific logic here.
3
3
#
4
- cmake_minimum_required (VERSION 3.8 )
4
+ cmake_minimum_required (VERSION 3.24 )
5
5
6
6
set (root_header_files
7
7
"../../include/modern_win32/access_denied_exception.h"
@@ -68,7 +68,11 @@ set(source_files
68
68
69
69
# Add source to this project's executable.
70
70
71
- add_definitions (-DMODERN_WIN32_EXPORTS -DUNICODE -D_UNICODE)
71
+ if (CMAKE_BUILD_TYPE MATCHES "Release" )
72
+ add_definitions (-DMODERN_WIN32_EXPORTS -DUNICODE -D_UNICODE -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -D_MBCS -DWIN32 -D_WINDOWS)
73
+ else ()
74
+ add_definitions (-DMODERN_WIN32_EXPORTS -DUNICODE -D_UNICODE -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_DEBUG -D_MBCS)
75
+ endif ()
72
76
73
77
add_library (modern_win32 SHARED ${source_files} ${public_header_files} )
74
78
@@ -80,24 +84,38 @@ generate_export_header(modern_win32)
80
84
set_target_properties (modern_win32 PROPERTIES VS_GLOBAL_KEYWORD "Win32Proj" )
81
85
set_target_properties (modern_win32 PROPERTIES EXPORT_NAME modern_win32)
82
86
87
+
83
88
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
84
89
message (status " using msvc compiler" )
85
90
set (MSVC_TOOLSET_VERSION 143)
86
91
87
- if (${USE_SPECTRE} MATCHES "true" )
88
- message (status " Spectre is enabled, adding /QSpectre flag" )
89
- target_compile_options (modern_win32 PRIVATE /Zi /Qspectre /guard:cf /MP)
90
- target_link_options (modern_win32 PRIVATE /DYNAMICBASE)
91
-
92
- else ()
93
- message (status " Spectre is not enabled" )
94
- #target_compile_options(modern_win32 PRIVATE /Zi /MP)
95
- target_compile_options (modern_win32 PRIVATE /Zi /Qspectre /guard:cf /MP)
96
- target_link_options (modern_win32 PRIVATE /DYNAMICBASE)
97
- endif ()
92
+ message (status " ${CMAKE_CXX_FLAGS_RELEASE} " )
93
+ set (CMAKE_CXX_FLAGS "/W4 /GR /GS /EHsc /wd4100 /wd4206 /wd4702 /wd6255 /nologo /diagnostics:column /std:c++20 /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /Zc:wchar_t /Zi /Gm- /we4715 /we4172" )
94
+ set (CMAKE_CXX_FLAGS_RELEASE "/MP /Gy /O2 /Gd /Oi /MD /FC" )
95
+ set (CMAKE_CXX_FLAGS_DEBUG "/JMC /MP /we4172 /GS /Od /RTC1 /Gd /MDd " )
96
+ message (status " after ${CMAKE_CXX_FLAGS} " )
97
+ message (status " after ${CMAKE_CXX_FLAGS_RELEASE} " )
98
98
99
99
if (CMAKE_BUILD_TYPE MATCHES "Release" )
100
+ if (${USE_SPECTRE} MATCHES "true" )
101
+ message (status " Spectre is enabled, adding /QSpectre flag" )
102
+ target_compile_options (modern_win32 PRIVATE /Qspectre)
103
+
104
+ target_link_options (modern_win32 PRIVATE /DYNAMICBASE)
105
+
106
+ else ()
107
+ message (status " Spectre is not enabled" )
108
+ endif ()
109
+
100
110
else ()
111
+ if (${USE_SPECTRE} MATCHES "true" )
112
+ message (status " Spectre is enabled, adding /QSpectre flag" )
113
+ target_compile_options (modern_win32 PRIVATE /Qspectre)
114
+
115
+ target_link_options (modern_win32 PRIVATE /DYNAMICBASE)
116
+ else ()
117
+ message (status " Spectre is not enabled" )
118
+ endif ()
101
119
endif ()
102
120
103
121
# Tell linker to include symbol data
@@ -111,8 +129,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
111
129
COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR}
112
130
)
113
131
114
- set_property (TARGET modern_win32 PROPERTY
115
- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
132
+ set_property (TARGET modern_win32 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" )
116
133
endif ()
117
134
118
135
target_include_directories (modern_win32
0 commit comments