mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[CMAKE]
- merge set_module_type function into the global CMakeMacros.cmake file, leaving compiler particular bits to set_module_type_toolchain function. - Add the ENTRYPOINT and BASEADDRESS options to this function. Not used yet svn path=/trunk/; revision=53553
This commit is contained in:
parent
2b4d045b85
commit
245ed2469c
4 changed files with 110 additions and 90 deletions
|
@ -239,3 +239,96 @@ function(add_importlibs _module)
|
|||
add_dependency_edge(${_module} ${LIB})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(set_module_type MODULE TYPE)
|
||||
cmake_parse_arguments(__module "" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
|
||||
|
||||
# Set subsystem. Also take this as an occasion
|
||||
# to error out if someone gave a non existing type
|
||||
if((${TYPE} STREQUAL nativecui) OR (${TYPE} STREQUAL nativedll) OR (${TYPE} STREQUAL kernelmodedriver))
|
||||
set(__subsystem native)
|
||||
elseif(${TYPE} STREQUAL win32cui)
|
||||
set(__subsystem console)
|
||||
elseif(${TYPE} STREQUAL win32gui)
|
||||
set(__subsystem windows)
|
||||
elseif(NOT ((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx) OR (${TYPE} STREQUAL cpl)))
|
||||
message(FATAL_ERROR "Unknown type ${TYPE} for module ${MODULE}")
|
||||
endif()
|
||||
|
||||
if(DEFINED __subsystem)
|
||||
set_subsystem(${MODULE} ${__subsystem})
|
||||
endif()
|
||||
|
||||
if(__module_UNPARSED_ARGUMENTS)
|
||||
message(STATUS ${__module_UNPARSED_ARGUMENTS})
|
||||
endif()
|
||||
|
||||
# set entry point
|
||||
if(__module_ENTRYPOINT)
|
||||
list(GET __module_ENTRYPOINT 0 __entrypoint)
|
||||
list(LENGTH __module_ENTRYPOINT __length)
|
||||
if(${__length} EQUAL 2)
|
||||
list(GET __module_ENTRYPOINT 1 __entrystack)
|
||||
elseif(NOT ${__length} EQUAL 1)
|
||||
message(FATAL_ERROR "Wrong arguments for ENTRYPOINT parameter of set_module_type : ${__module_ENTRYPOINT}")
|
||||
endif()
|
||||
unset(__length)
|
||||
elseif(${TYPE} STREQUAL nativecui)
|
||||
set(__entrypoint NtProcessStartup)
|
||||
set(__entrystack 4)
|
||||
elseif((${TYPE} STREQUAL win32gui) OR (${TYPE} STREQUAL win32cui))
|
||||
if(IS_UNICODE)
|
||||
set(__entrypoint wWinMainCRTStartup)
|
||||
else()
|
||||
set(__entrypoint WinMainCRTStartup)
|
||||
endif(IS_UNICODE)
|
||||
elseif((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
|
||||
OR (${TYPE} STREQUAL cpl))
|
||||
set(__entrypoint DllMainCRTStartup)
|
||||
set(__entrystack 12)
|
||||
elseif(${TYPE} STREQUAL kernelmodedriver)
|
||||
set(__entrypoint DriverEntry)
|
||||
set(__entrystack 8)
|
||||
elseif(${TYPE} STREQUAL nativedll)
|
||||
set(__entrypoint DllMain)
|
||||
set(__entrystack 12)
|
||||
endif()
|
||||
|
||||
if(DEFINED __entrypoint)
|
||||
if(DEFINED __entrystack)
|
||||
set_entrypoint(${MODULE} ${__entrypoint} ${__entrystack})
|
||||
else()
|
||||
set_entrypoint(${MODULE} ${__entrypoint})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#set base address
|
||||
if(__module_IMAGEBASE)
|
||||
set_image_base(${MODULE} __module_IMAGEBASE)
|
||||
elseif(${TYPE} STREQUAL win32dll)
|
||||
if(DEFINED baseaddress_${MODULE})
|
||||
set_image_base(${MODULE} ${baseaddress_${MODULE}})
|
||||
else()
|
||||
message(STATUS "${MODULE} has no base address")
|
||||
endif()
|
||||
elseif(${TYPE} STREQUAL kernelmodedriver)
|
||||
set_image_base(${MODULE} 0x00010000)
|
||||
endif()
|
||||
|
||||
# Now do some stuff which is specific to each type
|
||||
if(${TYPE} STREQUAL kernelmodedriver)
|
||||
add_dependencies(${MODULE} bugcodes)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
|
||||
endif()
|
||||
|
||||
if(${TYPE} STREQUAL win32ocx)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
|
||||
endif()
|
||||
|
||||
if(${TYPE} STREQUAL cpl)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
|
||||
endif()
|
||||
|
||||
# do compiler specific stuff
|
||||
set_module_type_toolchain(${MODULE} ${TYPE})
|
||||
endfunction()
|
||||
|
|
|
@ -96,3 +96,14 @@ macro(set_unicode)
|
|||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
set(IS_UNICODE 1)
|
||||
endmacro()
|
||||
|
||||
function(add_compiler_flags_target __module)
|
||||
get_target_property(__flags ${__module} COMPILE_FLAGS)
|
||||
if(NOT __flags)
|
||||
set(__flags "")
|
||||
endif()
|
||||
foreach(flag ${ARGN})
|
||||
set(__flags "${__flags} ${flag}")
|
||||
endforeach()
|
||||
set_target_properties(${__module} PROPERTIES COMPILE_FLAGS ${__flags})
|
||||
endfunction()
|
||||
|
|
|
@ -120,55 +120,13 @@ function(set_image_base MODULE IMAGE_BASE)
|
|||
add_target_link_flags(${MODULE} "-Wl,--image-base,${IMAGE_BASE}")
|
||||
endfunction()
|
||||
|
||||
function(set_module_type MODULE TYPE)
|
||||
|
||||
add_dependencies(${MODULE} psdk)
|
||||
if(${IS_CPP})
|
||||
function(set_module_type_toolchain MODULE TYPE)
|
||||
if(IS_CPP)
|
||||
target_link_libraries(${MODULE} stlport -lsupc++ -lgcc)
|
||||
endif()
|
||||
|
||||
if(${TYPE} MATCHES nativecui)
|
||||
set_subsystem(${MODULE} native)
|
||||
set_entrypoint(${MODULE} NtProcessStartup 4)
|
||||
elseif(${TYPE} MATCHES win32gui)
|
||||
set_subsystem(${MODULE} windows)
|
||||
if(IS_UNICODE)
|
||||
set_entrypoint(${MODULE} wWinMainCRTStartup)
|
||||
else()
|
||||
set_entrypoint(${MODULE} WinMainCRTStartup)
|
||||
endif(IS_UNICODE)
|
||||
elseif(${TYPE} MATCHES win32cui)
|
||||
set_subsystem(${MODULE} console)
|
||||
if(IS_UNICODE)
|
||||
set_entrypoint(${MODULE} wmainCRTStartup)
|
||||
else()
|
||||
set_entrypoint(${MODULE} mainCRTStartup)
|
||||
endif(IS_UNICODE)
|
||||
elseif(${TYPE} MATCHES win32dll)
|
||||
set_entrypoint(${MODULE} DllMainCRTStartup 12)
|
||||
if(DEFINED baseaddress_${MODULE})
|
||||
set_image_base(${MODULE} ${baseaddress_${MODULE}})
|
||||
else()
|
||||
message(STATUS "${MODULE} has no base address")
|
||||
endif()
|
||||
elseif(${TYPE} MATCHES win32ocx)
|
||||
set_entrypoint(${MODULE} DllMainCRTStartup 12)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
|
||||
elseif(${TYPE} MATCHES cpl)
|
||||
set_entrypoint(${MODULE} DllMainCRTStartup 12)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
|
||||
elseif(${TYPE} MATCHES kernelmodedriver)
|
||||
if(${TYPE} STREQUAL kernelmodedriver)
|
||||
add_target_link_flags(${MODULE} "-Wl,--exclude-all-symbols -Wl,-file-alignment=0x1000 -Wl,-section-alignment=0x1000")
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
|
||||
set_entrypoint(${MODULE} DriverEntry 8)
|
||||
set_subsystem(${MODULE} native)
|
||||
set_image_base(${MODULE} 0x00010000)
|
||||
add_dependencies(${MODULE} bugcodes)
|
||||
elseif(${TYPE} MATCHES nativedll)
|
||||
set_subsystem(${MODULE} native)
|
||||
set_entrypoint(${MODULE} DllMain 12)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown module type : ${TYPE}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
|
@ -81,53 +81,11 @@ function(set_image_base MODULE IMAGE_BASE)
|
|||
add_target_link_flags(${MODULE} "/BASE:${IMAGE_BASE}")
|
||||
endfunction()
|
||||
|
||||
function(set_module_type MODULE TYPE)
|
||||
add_dependencies(${MODULE} psdk)
|
||||
if(${TYPE} MATCHES nativecui)
|
||||
set_subsystem(${MODULE} native)
|
||||
set_entrypoint(${MODULE} NtProcessStartup 4)
|
||||
elseif (${TYPE} MATCHES win32gui)
|
||||
set_subsystem(${MODULE} windows)
|
||||
if(IS_UNICODE)
|
||||
set_entrypoint(${MODULE} wWinMainCRTStartup)
|
||||
else()
|
||||
set_entrypoint(${MODULE} WinMainCRTStartup)
|
||||
endif(IS_UNICODE)
|
||||
elseif (${TYPE} MATCHES win32cui)
|
||||
set_subsystem(${MODULE} console)
|
||||
if(IS_UNICODE)
|
||||
set_entrypoint(${MODULE} wmainCRTStartup)
|
||||
else()
|
||||
set_entrypoint(${MODULE} mainCRTStartup)
|
||||
endif(IS_UNICODE)
|
||||
elseif(${TYPE} MATCHES win32dll)
|
||||
# Need this only because mingw library is broken
|
||||
set_entrypoint(${MODULE} DllMainCRTStartup 12)
|
||||
if(DEFINED baseaddress_${MODULE})
|
||||
set_image_base(${MODULE} ${baseaddress_${MODULE}})
|
||||
else()
|
||||
message(STATUS "${MODULE} has no base address")
|
||||
endif()
|
||||
function(set_module_type_toolchain MODULE TYPE)
|
||||
if((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx) OR (${TYPE} STREQUAL cpl))
|
||||
add_target_link_flags(${MODULE} "/DLL")
|
||||
elseif(${TYPE} MATCHES win32ocx)
|
||||
set_entrypoint(${MODULE} DllMainCRTStartup 12)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
|
||||
add_target_link_flags(${MODULE} "/DLL")
|
||||
elseif(${TYPE} MATCHES cpl)
|
||||
set_entrypoint(${MODULE} DllMainCRTStartup 12)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
|
||||
add_target_link_flags(${MODULE} "/DLL")
|
||||
elseif(${TYPE} MATCHES kernelmodedriver)
|
||||
set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
|
||||
set_entrypoint(${MODULE} DriverEntry 8)
|
||||
set_subsystem(${MODULE} native)
|
||||
set_image_base(${MODULE} 0x00010000)
|
||||
elseif(${TYPE} STREQUAL kernelmodedriver)
|
||||
add_target_link_flags(${MODULE} "/DRIVER")
|
||||
add_dependencies(${MODULE} bugcodes)
|
||||
elseif(${TYPE} MATCHES nativedll)
|
||||
set_subsystem(${MODULE} native)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown module type : ${TYPE}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
Loading…
Reference in a new issue