[CMAKE] Properly handle hotpatchable flags requirements in MSVC builds. CORE-10477

svn path=/trunk/; revision=69812
This commit is contained in:
Amine Khaldi 2015-11-04 18:06:16 +00:00
parent 9d73134228
commit a25be55cc2
16 changed files with 26 additions and 30 deletions

View file

@ -540,7 +540,7 @@ function(add_importlibs _module)
endfunction()
function(set_module_type MODULE TYPE)
cmake_parse_arguments(__module "UNICODE;HOTPATCHABLE" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
cmake_parse_arguments(__module "UNICODE" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
if(__module_UNPARSED_ARGUMENTS)
message(STATUS "set_module_type : unparsed arguments ${__module_UNPARSED_ARGUMENTS}, module : ${MODULE}")
@ -574,17 +574,6 @@ function(set_module_type MODULE TYPE)
add_target_compile_definitions(${MODULE} UNICODE _UNICODE)
endif()
# Handle hotpatchable images.
# GCC has this as a function attribute so we're handling it using DECLSPEC_HOTPATCH
if(__module_HOTPATCHABLE AND MSVC AND (NOT ARCH STREQUAL "arm"))
if(ARCH STREQUAL "i386")
set_property(TARGET ${MODULE} APPEND_STRING PROPERTY COMPILE_FLAGS " /hotpatch")
set_property(TARGET ${MODULE} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:5")
elseif(ARCH STREQUAL "amd64")
set_property(TARGET ${MODULE} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:6")
endif()
endif()
# set entry point
if(__module_ENTRYPOINT OR (__module_ENTRYPOINT STREQUAL "0"))
list(GET __module_ENTRYPOINT 0 __entrypoint)

View file

@ -95,6 +95,14 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions("/D NDEBUG")
endif()
# Hotpatchable images
if(ARCH STREQUAL "i386")
add_compile_flags("/hotpatch")
set(_hotpatch_link_flag "/FUNCTIONPADMIN:5")
elseif(ARCH STREQUAL "amd64")
set(_hotpatch_link_flag "/FUNCTIONPADMIN:6")
endif()
if(MSVC_IDE AND (NOT DEFINED USE_FOLDER_STRUCTURE))
set(USE_FOLDER_STRUCTURE FALSE)
endif()
@ -108,9 +116,9 @@ if(RUNTIME_CHECKS)
add_compile_flags("/RTC1")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE /IGNORE:4104")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE /IGNORE:4104 ${_hotpatch_link_flag}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag}")
if(CMAKE_DISABLE_NINJA_DEPSLOG)
set(cl_includes_flag "")

View file

@ -25,7 +25,7 @@ add_library(d3d8 SHARED
version.rc
${CMAKE_CURRENT_BINARY_DIR}/d3d8.def)
set_module_type(d3d8 win32dll UNICODE HOTPATCHABLE)
set_module_type(d3d8 win32dll UNICODE)
target_link_libraries(d3d8 uuid wine)
add_importlibs(d3d8 d3dwine msvcrt kernel32 ntdll)
add_pch(d3d8 d3d8_private.h SOURCE)

View file

@ -28,7 +28,7 @@ add_library(d3d9 SHARED
${CMAKE_CURRENT_BINARY_DIR}/d3d9_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/d3d9.def)
set_module_type(d3d9 win32dll UNICODE HOTPATCHABLE)
set_module_type(d3d9 win32dll UNICODE)
target_link_libraries(d3d9 wine)
add_importlibs(d3d9 d3dwine msvcrt kernel32 ntdll)
add_pch(d3d9 d3d9_private.h SOURCE)

View file

@ -34,7 +34,7 @@ add_library(ddraw SHARED
ddraw.rc
${CMAKE_CURRENT_BINARY_DIR}/ddraw.def)
set_module_type(ddraw win32dll HOTPATCHABLE)
set_module_type(ddraw win32dll)
target_link_libraries(ddraw wine uuid dxguid ${PSEH_LIB})
add_importlibs(ddraw advapi32 gdi32 user32 d3dwine msvcrt kernel32 ntdll)
add_dependencies(ddraw wineheaders)

View file

@ -24,7 +24,7 @@ add_library(dinput SHARED
add_library(dinput_data_formats data_formats.c)
add_dependencies(dinput_data_formats psdk)
set_module_type(dinput win32dll HOTPATCHABLE)
set_module_type(dinput win32dll)
target_link_libraries(dinput dxguid uuid wine)
add_importlibs(dinput comctl32 ole32 user32 advapi32 msvcrt kernel32 ntdll)
add_pch(dinput dinput_private.h SOURCE)

View file

@ -8,7 +8,7 @@ list(APPEND SOURCE
${CMAKE_CURRENT_BINARY_DIR}/dinput8.def)
add_library(dinput8 SHARED ${SOURCE} version.rc)
set_module_type(dinput8 win32dll HOTPATCHABLE)
set_module_type(dinput8 win32dll)
target_link_libraries(dinput8 dxguid uuid wine)
add_importlibs(dinput8 ole32 msvcrt kernel32 ntdll)
add_cd_file(TARGET dinput8 DESTINATION reactos/system32 FOR all)

View file

@ -43,7 +43,7 @@ add_library(ntdll SHARED
${CMAKE_CURRENT_BINARY_DIR}/ntdll_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/ntdll.def)
set_module_type(ntdll win32dll HOTPATCHABLE ENTRYPOINT 0)
set_module_type(ntdll win32dll ENTRYPOINT 0)
#############################################
## HACK FOR MSVC COMPILATION WITH win32dll ##
set_subsystem(ntdll console)

View file

@ -57,8 +57,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_libraries(opengl32 mingwex)
endif()
set_module_type(opengl32 win32dll HOTPATCHABLE)
set_module_type(opengl32 win32dll)
add_importlibs(opengl32 gdi32 user32 advapi32 msvcrt kernel32 ntdll)
add_pch(opengl32 opengl32.h SOURCE)
add_cd_file(TARGET opengl32 DESTINATION reactos/system32 FOR all)

View file

@ -25,7 +25,7 @@ add_library(iphlpapi SHARED
iphlpapi.rc
${CMAKE_CURRENT_BINARY_DIR}/iphlpapi.def)
set_module_type(iphlpapi win32dll UNICODE HOTPATCHABLE)
set_module_type(iphlpapi win32dll UNICODE)
target_link_libraries(iphlpapi wine tdilib)
add_importlibs(iphlpapi icmp dhcpcsvc advapi32 ws2_32 msvcrt kernel32 ntdll)
add_pch(iphlpapi iphlpapi_private.h SOURCE)

View file

@ -103,7 +103,7 @@ add_library(kernel32 SHARED
kernel32.rc
${CMAKE_CURRENT_BINARY_DIR}/kernel32.def)
set_module_type(kernel32 win32dll HOTPATCHABLE ENTRYPOINT DllMain 12)
set_module_type(kernel32 win32dll ENTRYPOINT DllMain 12)
#############################################
## HACK FOR MSVC COMPILATION WITH win32dll ##
set_subsystem(kernel32 console)

View file

@ -12,7 +12,7 @@ list(APPEND SOURCE
${CMAKE_CURRENT_BINARY_DIR}/kernel32_vista.def)
add_library(kernel32_vista SHARED ${SOURCE})
set_module_type(kernel32_vista win32dll HOTPATCHABLE ENTRYPOINT DllMain 12)
set_module_type(kernel32_vista win32dll ENTRYPOINT DllMain 12)
add_importlibs(kernel32_vista kernel32 ntdll)
add_dependencies(kernel32_vista psdk)
add_cd_file(TARGET kernel32_vista DESTINATION reactos/system32 FOR all)

View file

@ -81,7 +81,7 @@ add_library(shell32 SHARED
${CMAKE_CURRENT_BINARY_DIR}/shell32_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/shell32.def)
set_module_type(shell32 win32dll UNICODE HOTPATCHABLE)
set_module_type(shell32 win32dll UNICODE)
target_link_libraries(shell32 shellmenu shelldesktop atlnew wine uuid recyclebin)
add_delay_importlibs(shell32 uxtheme ole32 userenv version fmifs)
add_importlibs(shell32 advapi32 browseui gdi32 user32 powrprof comctl32 comdlg32 shdocvw shlwapi devmgr winspool winmm msvcrt kernel32 ntdll)

View file

@ -21,7 +21,7 @@ add_library(winmm SHARED
winmm_res.rc
${CMAKE_CURRENT_BINARY_DIR}/winmm.def)
set_module_type(winmm win32dll HOTPATCHABLE)
set_module_type(winmm win32dll)
target_link_libraries(winmm wine ${PSEH_LIB})
add_importlibs(winmm advapi32 user32 msvcrt kernel32 ntdll)
add_pch(winmm winemm.h SOURCE)

View file

@ -8,7 +8,7 @@ list(APPEND SOURCE
${CMAKE_CURRENT_BINARY_DIR}/xinput1_3.def)
add_library(xinput1_3 SHARED ${SOURCE} version.rc)
set_module_type(xinput1_3 win32dll HOTPATCHABLE)
set_module_type(xinput1_3 win32dll)
target_link_libraries(xinput1_3 wine)
add_importlibs(xinput1_3 msvcrt kernel32 ntdll)
add_cd_file(TARGET xinput1_3 DESTINATION reactos/system32 FOR all)

View file

@ -69,7 +69,7 @@ add_library(user32 SHARED
user32.rc
${CMAKE_CURRENT_BINARY_DIR}/user32.def)
set_module_type(user32 win32dll ENTRYPOINT DllMain 12 UNICODE HOTPATCHABLE)
set_module_type(user32 win32dll ENTRYPOINT DllMain 12 UNICODE)
target_link_libraries(user32 user32_wsprintf wine win32ksys ${PSEH_LIB})
if(MSVC)