# Warn about potentially uninitialized variables
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34701>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34703>")
+
+ if (NOT MSVC_VERSION LESS 1900)
+ # Enable control flow guard
+ message(STATUS "Building with control flow guard")
+ add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/guard:cf>")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf")
+ endif()
endif()
if(NOT WIN32)
<?xml version="1.0" encoding="utf-8"?>\r
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
<ItemGroup Label="ProjectConfigurations">\r
<ProjectConfiguration Include="Debug|Win32">\r
<Configuration>Debug</Configuration>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
<ConfigurationType>Application</ConfigurationType>\r
<UseDebugLibraries>true</UseDebugLibraries>\r
- <PlatformToolset>v120</PlatformToolset>\r
+ <PlatformToolset>v140</PlatformToolset>\r
<CharacterSet>MultiByte</CharacterSet>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
<ConfigurationType>Application</ConfigurationType>\r
<UseDebugLibraries>false</UseDebugLibraries>\r
- <PlatformToolset>v120</PlatformToolset>\r
+ <PlatformToolset>v140</PlatformToolset>\r
<WholeProgramOptimization>true</WholeProgramOptimization>\r
<CharacterSet>MultiByte</CharacterSet>\r
</PropertyGroup>\r
<Optimization>Disabled</Optimization>\r
<SDLCheck>false</SDLCheck>\r
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
+ <ControlFlowGuard>Guard</ControlFlowGuard>\r
</ClCompile>\r
<Link>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<IntrinsicFunctions>true</IntrinsicFunctions>\r
<SDLCheck>false</SDLCheck>\r
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
+ <ControlFlowGuard>Guard</ControlFlowGuard>\r
</ClCompile>\r
<Link>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
defenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS', '_CRT_NONSTDC_NO_WARNINGS', '_CRT_SECURE_NO_DEPRECATE', '_CRT_NON_CONFORMING_SWPRINTFS'])
defenv['MSVCRT_FLAG'] = '/MT' # Avoid msvcr?0.dll dependency
else:
-@@ -143,9 +143,9 @@ stub_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
+@@ -43,6 +43,10 @@ if msvs_version >= 11.0:
+ defenv['SUBSYS_CON'] = '/subsystem:console,5.01' # support windows xp
+ defenv['SUBSYS_WIN'] = '/subsystem:windows,5.01' # support windows xp
+
++if msvs_version >= 14.0:
++ defenv.Append(CCFLAGS = ['/guard:cf'])
++ defenv.Append(LINKFLAGS = ['/guard:cf'])
++
+ ### defines
+
+ defenv.Append(CPPDEFINES = [('NSISCALL', '$STDCALL')])
+@@ -143,9 +147,9 @@ stub_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name
stub_env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) # no default libraries
stub_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
Instructions for building NSIS are available at\r
http://nsis//sourceforge.net/Docs/AppendixG.html.\r
\r
- The security changes to NSIS involve adding the /DYMANICBASE and /GS options\r
- to the NSIS compile/link steps, so that the Runtime Installer and Uninstaller\r
- are built with address space layout randomization and buffer overrun checks.\r
+ The security changes to NSIS involve adding the /DYMANICBASE, /GS and\r
+ /guard:cf options to the NSIS compile/link steps, so that the Runtime\r
+ Installer and Uninstaller are built with address space layout randomization,\r
+ buffer overrun checks and control flow guard.\r
\r
The security changes to NSIS can be made by applying the patch in the\r
NSIS_Security.patch file in this folder.\r