File tree 1 file changed +17
-1
lines changed 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -197,11 +197,27 @@ if(WIN32 AND MSVC)
197
197
set ( CMAKE_DEBUG_POSTFIX "d" ) # little effect in unix
198
198
else ()
199
199
# add any gcc flags
200
+
201
+ set ( CFLAGS "${CFLAGS} -O2" )
202
+ # -O2: GCC performs nearly all supported optimizations that do not involve
203
+ # a space-speed tradeoff. As compared to '-O', this option increases
204
+ # both compilation time and the performance of the generated code.
205
+
206
+ set ( LDFLAGS "${LDFLAGS} -Wl,--nxcompat" )
207
+ # https://en.wikipedia.org/wiki/Data_Execution_Prevention
208
+ # Enable DEP with -Wl,--nxcompat
209
+
210
+ set ( LDFLAGS "-Wl,--dynamicbase,--export-all-symbols" )
211
+ # https://en.wikipedia.org/wiki/Address_space_layout_randomization
212
+ # https://stackoverflow.com/questions/24283918/how-can-i-enable-aslr-dep-and-safeseh-on-an-exe-in-codeblocks-using-mingw
213
+ # ASLR with gcc has a problem: -Wl,--dynamicbase doesn't emit the necessary relocation table.
214
+ # As a workaround, you can pass -Wl,--dynamicbase,--export-all-symbols
215
+
200
216
endif ()
201
217
202
218
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT" )
203
219
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT" )
204
- set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS} " )
220
+ set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LDFLAGS} ${ MSVC_LD_FLAGS} " )
205
221
206
222
207
223
#------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments