mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +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
|
@ -9,7 +9,7 @@ add_importlibs(welcome gdi32 user32 shell32 msvcrt kernel32 ntdll)
|
|||
if(ARCH STREQUAL "i386")
|
||||
if(MSVC)
|
||||
# NOTE: We cannot use the following command:
|
||||
# add_target_link_flags(welcome "/SUBSYSTEM:WINDOWS,4.00")
|
||||
# target_link_options(welcome PRIVATE "/SUBSYSTEM:WINDOWS,4.00")
|
||||
# because it would act at the level of the LINK.EXE linker flags,
|
||||
# which only accepts a subsystem version >= 5.10 (Windows XP+) on
|
||||
# latest MSVC versions.
|
||||
|
@ -23,7 +23,7 @@ if(ARCH STREQUAL "i386")
|
|||
else()
|
||||
# The binutils linker does not set a lower limit on the subsystem.
|
||||
# Otherwise we would use: objcopy --subsystem windows:4.00 $<TARGET_FILE:welcome>
|
||||
add_target_link_flags(welcome "-Wl,--subsystem,windows:4.00")
|
||||
target_link_options(welcome PRIVATE "-Wl,--subsystem,windows:4.00")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -83,12 +83,12 @@ set_target_properties(bootmgfw PROPERTIES SUFFIX ".efi")
|
|||
|
||||
if(MSVC)
|
||||
if(ARCH STREQUAL "arm")
|
||||
add_target_link_flags(bootmgfw "/ignore:4078 /ignore:4254 /DRIVER")
|
||||
target_link_options(bootmgfw PRIVATE /ignore:4078 /ignore:4254 /DRIVER)
|
||||
else()
|
||||
add_target_link_flags(bootmgfw "/ignore:4078 /ignore:4254 /DRIVER /DYNAMICBASE:NO /NXCOMPAT:NO /FIXED")
|
||||
target_link_options(bootmgfw PRIVATE /ignore:4078 /ignore:4254 /DRIVER /DYNAMICBASE:NO /NXCOMPAT:NO /FIXED)
|
||||
endif()
|
||||
else()
|
||||
add_target_link_flags(bootmgfw "-Wl,--strip-all,--exclude-all-symbols")
|
||||
target_link_options(bootmgfw PRIVATE "-Wl,--strip-all,--exclude-all-symbols")
|
||||
endif()
|
||||
|
||||
set_image_base(bootmgfw 0x10000)
|
||||
|
@ -130,9 +130,9 @@ add_executable(rosload ${ROSLOAD_BASE_SOURCE} ${rosload_asm})
|
|||
set_target_properties(rosload PROPERTIES SUFFIX ".efi")
|
||||
|
||||
if(MSVC)
|
||||
add_target_link_flags(rosload "/ignore:4078 /ignore:4254 /DRIVER")
|
||||
target_link_options(rosload PRIVATE /ignore:4078 /ignore:4254 /DRIVER)
|
||||
else()
|
||||
add_target_link_flags(rosload "-Wl,--strip-all,--exclude-all-symbols,--dynamicbase,--pic-executable")
|
||||
target_link_options(rosload PRIVATE "-Wl,--strip-all,--exclude-all-symbols,--dynamicbase,--pic-executable")
|
||||
endif()
|
||||
|
||||
set_image_base(rosload 0x10000)
|
||||
|
|
|
@ -266,7 +266,7 @@ set_target_properties(freeldr_pe
|
|||
|
||||
if(MSVC)
|
||||
if(ARCH STREQUAL "arm")
|
||||
add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER")
|
||||
target_link_options(freeldr_pe PRIVATE /ignore:4078 /ignore:4254 /DRIVER)
|
||||
else()
|
||||
target_link_options(freeldr_pe PRIVATE /ignore:4078 /ignore:4254 /DYNAMICBASE:NO /FIXED /FILEALIGN:512 /ALIGN:512)
|
||||
add_linker_script(freeldr_pe freeldr_i386.msvc.lds)
|
||||
|
@ -301,7 +301,7 @@ endif()
|
|||
|
||||
if(RUNTIME_CHECKS)
|
||||
target_link_libraries(freeldr_pe runtmchk)
|
||||
add_target_link_flags(freeldr_pe "/MERGE:.rtc=.text")
|
||||
target_link_options(freeldr_pe PRIVATE "/MERGE:.rtc=.text")
|
||||
endif()
|
||||
|
||||
add_dependencies(freeldr_pe asm)
|
||||
|
|
|
@ -99,10 +99,10 @@ foreach(_keyboard_layout ${_keyboard_layouts})
|
|||
|
||||
if(MSVC)
|
||||
# Merge the .text and .rdata section into the .data section
|
||||
add_target_link_flags(${_keyboard_layout} "/ignore:4254 /SECTION:.data,ER /MERGE:.text=.data /MERGE:.rdata=.data /MERGE:.bss=.data /MERGE:.edata=.data")
|
||||
target_link_options(${_keyboard_layout} PRIVATE "/ignore:4254;/SECTION:.data,ER;/MERGE:.text=.data;/MERGE:.rdata=.data;/MERGE:.bss=.data;/MERGE:.edata=.data")
|
||||
else()
|
||||
# Use a custom linker script
|
||||
add_target_link_flags(${_keyboard_layout} "-Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/kbdlayout.lds")
|
||||
target_link_options(${_keyboard_layout} PRIVATE "-Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/kbdlayout.lds")
|
||||
|
||||
# Avoid "universal character names are only valid in C++ and C99" error.
|
||||
set_property(TARGET ${_keyboard_layout} PROPERTY C_STANDARD 99)
|
||||
|
|
|
@ -60,10 +60,6 @@ set_module_type(ntdll win32dll ENTRYPOINT 0)
|
|||
set_subsystem(ntdll console)
|
||||
################# END HACK #################
|
||||
|
||||
if(MSVC)
|
||||
add_target_link_flags(ntdll "/RELEASE")
|
||||
endif()
|
||||
|
||||
target_link_libraries(ntdll rtl ntdllsys libcntpr uuid ${PSEH_LIB})
|
||||
|
||||
if (STACK_PROTECTOR)
|
||||
|
|
|
@ -60,7 +60,7 @@ endif()
|
|||
if(NOT MSVC)
|
||||
# Binutils linker bug
|
||||
if(LTCG)
|
||||
add_target_link_flags(browseui "-Wl,--allow-multiple-definition")
|
||||
target_link_options(browseui PRIVATE "-Wl,--allow-multiple-definition")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ target_link_libraries(msvcrt20 crt wine ${PSEH_LIB})
|
|||
|
||||
if(MSVC)
|
||||
# export of deleting destructor "name"
|
||||
add_target_link_flags(msvcrt20 "/ignore:4102")
|
||||
target_link_options(msvcrt20 PRIVATE /ignore:4102)
|
||||
endif()
|
||||
|
||||
add_importlibs(msvcrt20 kernel32 ntdll)
|
||||
|
|
|
@ -25,7 +25,7 @@ target_link_libraries(msvcrt40 crt wine ${PSEH_LIB})
|
|||
|
||||
if(MSVC)
|
||||
# export of deleting destructor "name"
|
||||
add_target_link_flags(msvcrt40 "/ignore:4102")
|
||||
target_link_options(msvcrt40 PRIVATE /ignore:4102)
|
||||
endif()
|
||||
|
||||
add_importlibs(msvcrt40 kernel32 ntdll)
|
||||
|
|
|
@ -34,7 +34,7 @@ function(add_hal _halname)
|
|||
set_module_type(${_halname} kerneldll ENTRYPOINT HalInitSystem 8)
|
||||
add_cd_file(TARGET ${_halname} DESTINATION reactos/system32 NO_CAB FOR all)
|
||||
if(MSVC)
|
||||
add_target_link_flags(${_halname} "/ignore:4216 /SECTION:INIT,ERWD")
|
||||
target_link_options(${_halname} PRIVATE /ignore:4216 /SECTION:INIT,ERWD)
|
||||
else()
|
||||
target_link_libraries(${_halname} -lgcc)
|
||||
endif()
|
||||
|
|
|
@ -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…
Reference in a new issue