mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:12:59 +00:00
[CMAKE] Replace custom scripts in compilerflags with standard ones
- add_target_link_flags changed to target_link_options - add_target_property changed to set_property(... APPEND ...)
This commit is contained in:
parent
233c74e25a
commit
8e1fa03456
12 changed files with 34 additions and 79 deletions
|
@ -1,29 +1,4 @@
|
|||
|
||||
# add_target_property
|
||||
# Adds one or more values to the specified property of the specified target.
|
||||
# Note that there are properties which require (semicolon-separated) lists,
|
||||
# while others require space-separated strings. The function has a list of
|
||||
# properties of the former variety and handles the values accordingly
|
||||
function(add_target_property _module _propname)
|
||||
list(APPEND _list_properties COMPILE_DEFINITIONS INCLUDE_DIRECTORIES LINK_DEPENDS)
|
||||
set(_newvalue "")
|
||||
get_target_property(_oldvalue ${_module} ${_propname})
|
||||
if(_oldvalue)
|
||||
set(_newvalue ${_oldvalue})
|
||||
endif()
|
||||
list(FIND _list_properties ${_propname} _list_index)
|
||||
if(NOT _list_index EQUAL -1)
|
||||
# list property
|
||||
list(APPEND _newvalue ${ARGN})
|
||||
else()
|
||||
# string property
|
||||
foreach(_flag ${ARGN})
|
||||
set(_newvalue "${_newvalue} ${_flag}")
|
||||
endforeach()
|
||||
endif()
|
||||
set_property(TARGET ${_module} PROPERTY ${_propname} ${_newvalue})
|
||||
endfunction()
|
||||
|
||||
# remove_target_compile_options
|
||||
# Remove one option from the target COMPILE_OPTIONS property,
|
||||
# previously added through add_compile_options
|
||||
|
@ -32,19 +7,3 @@ function(remove_target_compile_option _module _option)
|
|||
list(REMOVE_ITEM _options ${_option})
|
||||
set_target_properties(${_module} PROPERTIES COMPILE_OPTIONS "${_options}")
|
||||
endfunction()
|
||||
|
||||
# Wrapper functions for the important properties, using add_target_property
|
||||
# where appropriate.
|
||||
# Note that the functions for string properties take a single string
|
||||
# argument while those for list properties can take a variable number of
|
||||
# arguments, all of which will be added to the list
|
||||
#
|
||||
# Examples:
|
||||
# add_target_link_flags(mymodule "-s --fatal-warnings")
|
||||
|
||||
function(add_target_link_flags _module _flags)
|
||||
if(${ARGC} GREATER 2)
|
||||
message(FATAL_ERROR "Excess arguments to add_target_link_flags! Module ${_module}, args ${ARGN}")
|
||||
endif()
|
||||
add_target_property(${_module} LINK_FLAGS ${_flags})
|
||||
endfunction()
|
||||
|
|
|
@ -277,24 +277,24 @@ set(CMAKE_DEPFILE_FLAGS_RC "--preprocessor=\"${CMAKE_C_COMPILER}\" ${RC_PREPROCE
|
|||
# Optional 3rd parameter: stdcall stack bytes
|
||||
function(set_entrypoint MODULE ENTRYPOINT)
|
||||
if(${ENTRYPOINT} STREQUAL "0")
|
||||
add_target_link_flags(${MODULE} "-Wl,-entry,0")
|
||||
target_link_options(${MODULE} PRIVATE "-Wl,-entry,0")
|
||||
elseif(ARCH STREQUAL "i386")
|
||||
set(_entrysymbol _${ENTRYPOINT})
|
||||
if(${ARGC} GREATER 2)
|
||||
set(_entrysymbol ${_entrysymbol}@${ARGV2})
|
||||
endif()
|
||||
add_target_link_flags(${MODULE} "-Wl,-entry,${_entrysymbol}")
|
||||
target_link_options(${MODULE} PRIVATE "-Wl,-entry,${_entrysymbol}")
|
||||
else()
|
||||
add_target_link_flags(${MODULE} "-Wl,-entry,${ENTRYPOINT}")
|
||||
target_link_options(${MODULE} PRIVATE "-Wl,-entry,${ENTRYPOINT}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(set_subsystem MODULE SUBSYSTEM)
|
||||
add_target_link_flags(${MODULE} "-Wl,--subsystem,${SUBSYSTEM}:5.01")
|
||||
target_link_options(${MODULE} PRIVATE "-Wl,--subsystem,${SUBSYSTEM}:5.01")
|
||||
endfunction()
|
||||
|
||||
function(set_image_base MODULE IMAGE_BASE)
|
||||
add_target_link_flags(${MODULE} "-Wl,--image-base,${IMAGE_BASE}")
|
||||
target_link_options(${MODULE} PRIVATE "-Wl,--image-base,${IMAGE_BASE}")
|
||||
endfunction()
|
||||
|
||||
function(set_module_type_toolchain MODULE TYPE)
|
||||
|
@ -476,8 +476,8 @@ endmacro()
|
|||
|
||||
function(add_linker_script _target _linker_script_file)
|
||||
get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
|
||||
add_target_link_flags(${_target} "-Wl,-T,${_file_full_path}")
|
||||
add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
|
||||
target_link_options(${_target} PRIVATE "-Wl,-T,${_file_full_path}")
|
||||
set_property(TARGET ${_target} APPEND PROPERTY LINK_DEPENDS ${_file_full_path})
|
||||
endfunction()
|
||||
|
||||
# Manage our C++ options
|
||||
|
|
|
@ -238,31 +238,31 @@ set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
|
|||
|
||||
function(set_entrypoint _module _entrypoint)
|
||||
if(${_entrypoint} STREQUAL "0")
|
||||
add_target_link_flags(${_module} "/NOENTRY")
|
||||
target_link_options(${_module} PRIVATE "/NOENTRY")
|
||||
elseif(ARCH STREQUAL "i386")
|
||||
set(_entrysymbol ${_entrypoint})
|
||||
if(${ARGC} GREATER 2)
|
||||
set(_entrysymbol ${_entrysymbol}@${ARGV2})
|
||||
endif()
|
||||
add_target_link_flags(${_module} "/ENTRY:${_entrysymbol}")
|
||||
target_link_options(${_module} PRIVATE "/ENTRY:${_entrysymbol}")
|
||||
else()
|
||||
add_target_link_flags(${_module} "/ENTRY:${_entrypoint}")
|
||||
target_link_options(${_module} PRIVATE "/ENTRY:${_entrypoint}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(set_subsystem MODULE SUBSYSTEM)
|
||||
string(TOUPPER ${SUBSYSTEM} _subsystem)
|
||||
if(ARCH STREQUAL "amd64")
|
||||
add_target_link_flags(${MODULE} "/SUBSYSTEM:${_subsystem},5.02")
|
||||
target_link_options(${MODULE} PRIVATE "/SUBSYSTEM:${_subsystem},5.02")
|
||||
elseif(ARCH STREQUAL "arm")
|
||||
add_target_link_flags(${MODULE} "/SUBSYSTEM:${_subsystem},6.02")
|
||||
target_link_options(${MODULE} PRIVATE "/SUBSYSTEM:${_subsystem},6.02")
|
||||
else()
|
||||
add_target_link_flags(${MODULE} "/SUBSYSTEM:${_subsystem},5.01")
|
||||
target_link_options(${MODULE} PRIVATE "/SUBSYSTEM:${_subsystem},5.01")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(set_image_base MODULE IMAGE_BASE)
|
||||
add_target_link_flags(${MODULE} "/BASE:${IMAGE_BASE}")
|
||||
target_link_options(${MODULE} PRIVATE "/BASE:${IMAGE_BASE}")
|
||||
endfunction()
|
||||
|
||||
function(set_module_type_toolchain MODULE TYPE)
|
||||
|
@ -302,7 +302,7 @@ function(add_delay_importlibs _module)
|
|||
if(NOT _ext)
|
||||
set(_ext ".dll")
|
||||
endif()
|
||||
add_target_link_flags(${_module} "/DELAYLOAD:${_basename}${_ext}")
|
||||
target_link_options(${_module} PRIVATE "/DELAYLOAD:${_basename}${_ext}")
|
||||
target_link_libraries(${_module} "lib${_basename}")
|
||||
endforeach()
|
||||
target_link_libraries(${_module} delayimp)
|
||||
|
@ -538,8 +538,8 @@ function(add_linker_script _target _linker_script_file)
|
|||
message(FATAL_ERROR "Generating pre-processed linker options for target '${_target}' failed with error ${linker_rsp_result}.")
|
||||
endif()
|
||||
# file(STRINGS ${_generated_file} linker_options NEWLINE_CONSUME)
|
||||
string(REGEX REPLACE "[\r\n]+" " " linker_options "${linker_options}")
|
||||
add_target_link_flags(${_target} ${linker_options})
|
||||
string(REGEX REPLACE "[\r\n]+" ";" linker_options "${linker_options}")
|
||||
target_link_options(${_target} PRIVATE ${linker_options})
|
||||
else()
|
||||
# Generate at compile-time a linker response file and append it
|
||||
# to the linker command-line.
|
||||
|
@ -552,8 +552,8 @@ function(add_linker_script _target _linker_script_file)
|
|||
set_source_files_properties(${_generated_file} PROPERTIES GENERATED TRUE)
|
||||
# add_custom_target("${_target}_${_file_name}" ALL DEPENDS ${_generated_file})
|
||||
# add_dependencies(${_target} "${_target}_${_file_name}")
|
||||
add_target_link_flags(${_target} "@${_generated_file}")
|
||||
add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
|
||||
target_link_options(${_target} PRIVATE "@${_generated_file}")
|
||||
set_property(TARGET ${_target} APPEND PROPERTY LINK_DEPENDS ${_file_full_path})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue