mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 16:40:27 +00:00
[CMAKE] Move toolchain specific handling to set_module_type_toolchain
+ style fixes
This commit is contained in:
parent
5c21460680
commit
f5bace8536
3 changed files with 14 additions and 11 deletions
|
@ -574,14 +574,6 @@ function(set_module_type MODULE TYPE)
|
||||||
set_subsystem(${MODULE} windows)
|
set_subsystem(${MODULE} windows)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set the PE image version numbers from the NT OS version ReactOS is based on
|
|
||||||
if(MSVC)
|
|
||||||
target_link_options(${MODULE} PRIVATE "/VERSION:5.01")
|
|
||||||
else()
|
|
||||||
target_link_options(${MODULE} PRIVATE
|
|
||||||
-Wl,--major-image-version,5 -Wl,--minor-image-version,01 -Wl,--major-os-version,5 -Wl,--minor-os-version,01)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Set unicode definitions
|
# Set unicode definitions
|
||||||
if(__module_UNICODE)
|
if(__module_UNICODE)
|
||||||
target_compile_definitions(${MODULE} PRIVATE UNICODE _UNICODE)
|
target_compile_definitions(${MODULE} PRIVATE UNICODE _UNICODE)
|
||||||
|
@ -643,7 +635,7 @@ function(set_module_type MODULE TYPE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (TYPE STREQUAL kernel)
|
if(TYPE STREQUAL kernel)
|
||||||
# Kernels are executables with exports
|
# Kernels are executables with exports
|
||||||
set_property(TARGET ${MODULE} PROPERTY ENABLE_EXPORTS TRUE)
|
set_property(TARGET ${MODULE} PROPERTY ENABLE_EXPORTS TRUE)
|
||||||
set_target_properties(${MODULE} PROPERTIES DEFINE_SYMBOL "")
|
set_target_properties(${MODULE} PROPERTIES DEFINE_SYMBOL "")
|
||||||
|
|
|
@ -280,13 +280,20 @@ function(set_image_base MODULE IMAGE_BASE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(set_module_type_toolchain MODULE TYPE)
|
function(set_module_type_toolchain MODULE TYPE)
|
||||||
if (TYPE IN_LIST KERNEL_MODULE_TYPES)
|
# Set the PE image version numbers from the NT OS version ReactOS is based on
|
||||||
|
target_link_options(${MODULE} PRIVATE
|
||||||
|
-Wl,--major-image-version,5 -Wl,--minor-image-version,01 -Wl,--major-os-version,5 -Wl,--minor-os-version,01)
|
||||||
|
|
||||||
|
if(TYPE IN_LIST KERNEL_MODULE_TYPES)
|
||||||
target_link_options(${MODULE} PRIVATE -Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000)
|
target_link_options(${MODULE} PRIVATE -Wl,--exclude-all-symbols,-file-alignment=0x1000,-section-alignment=0x1000)
|
||||||
|
|
||||||
if(${TYPE} STREQUAL "wdmdriver")
|
if(${TYPE} STREQUAL "wdmdriver")
|
||||||
target_link_options(${MODULE} PRIVATE "-Wl,--wdmdriver")
|
target_link_options(${MODULE} PRIVATE "-Wl,--wdmdriver")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Place INIT &.rsrc section at the tail of the module, before .reloc
|
# Place INIT &.rsrc section at the tail of the module, before .reloc
|
||||||
add_linker_script(${MODULE} ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds)
|
add_linker_script(${MODULE} ${REACTOS_SOURCE_DIR}/sdk/cmake/init-section.lds)
|
||||||
|
|
||||||
# Fixup section characteristics
|
# Fixup section characteristics
|
||||||
# - Remove flags that LD overzealously puts (alignment flag, Initialized flags for code sections)
|
# - Remove flags that LD overzealously puts (alignment flag, Initialized flags for code sections)
|
||||||
# - INIT section is made discardable
|
# - INIT section is made discardable
|
||||||
|
@ -294,6 +301,7 @@ function(set_module_type_toolchain MODULE TYPE)
|
||||||
# - PAGE & .edata sections are made pageable.
|
# - PAGE & .edata sections are made pageable.
|
||||||
add_custom_command(TARGET ${MODULE} POST_BUILD
|
add_custom_command(TARGET ${MODULE} POST_BUILD
|
||||||
COMMAND native-pefixup --${TYPE} $<TARGET_FILE:${MODULE}>)
|
COMMAND native-pefixup --${TYPE} $<TARGET_FILE:${MODULE}>)
|
||||||
|
|
||||||
# Believe it or not, cmake doesn't do that
|
# Believe it or not, cmake doesn't do that
|
||||||
set_property(TARGET ${MODULE} APPEND PROPERTY LINK_DEPENDS $<TARGET_PROPERTY:native-pefixup,IMPORTED_LOCATION>)
|
set_property(TARGET ${MODULE} APPEND PROPERTY LINK_DEPENDS $<TARGET_PROPERTY:native-pefixup,IMPORTED_LOCATION>)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -249,6 +249,9 @@ function(set_image_base MODULE IMAGE_BASE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(set_module_type_toolchain MODULE TYPE)
|
function(set_module_type_toolchain MODULE TYPE)
|
||||||
|
# Set the PE image version numbers from the NT OS version ReactOS is based on
|
||||||
|
target_link_options(${MODULE} PRIVATE "/VERSION:5.01")
|
||||||
|
|
||||||
if((TYPE STREQUAL win32dll) OR (TYPE STREQUAL win32ocx) OR (TYPE STREQUAL cpl))
|
if((TYPE STREQUAL win32dll) OR (TYPE STREQUAL win32ocx) OR (TYPE STREQUAL cpl))
|
||||||
target_link_options(${MODULE} PRIVATE /DLL)
|
target_link_options(${MODULE} PRIVATE /DLL)
|
||||||
elseif(TYPE IN_LIST KERNEL_MODULE_TYPES)
|
elseif(TYPE IN_LIST KERNEL_MODULE_TYPES)
|
||||||
|
@ -261,7 +264,7 @@ function(set_module_type_toolchain MODULE TYPE)
|
||||||
target_link_options(${MODULE} PRIVATE /DRIVER:WDM)
|
target_link_options(${MODULE} PRIVATE /DRIVER:WDM)
|
||||||
elseif (TYPE STREQUAL kernel)
|
elseif (TYPE STREQUAL kernel)
|
||||||
# Mark .rsrc section as non-disposable non-pageable, as bugcheck code needs to access it
|
# Mark .rsrc section as non-disposable non-pageable, as bugcheck code needs to access it
|
||||||
target_link_options(${MODULE} PRIVATE /SECTION:.rsrc,!DP )
|
target_link_options(${MODULE} PRIVATE /SECTION:.rsrc,!DP)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue