https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e1fa03456a68bc6773d4…
commit 8e1fa03456a68bc6773d4f49ab8c18debe61d1c6
Author: Victor Perevertkin <victor.perevertkin(a)reactos.org>
AuthorDate: Mon Sep 13 19:51:08 2021 +0300
Commit: Victor Perevertkin <victor.perevertkin(a)reactos.org>
CommitDate: Tue Sep 14 17:56:22 2021 +0300
[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 ...)
---
base/setup/welcome/CMakeLists.txt | 4 ++--
boot/environ/CMakeLists.txt | 10 ++++-----
boot/freeldr/freeldr/CMakeLists.txt | 4 ++--
dll/keyboard/CMakeLists.txt | 4 ++--
dll/ntdll/CMakeLists.txt | 4 ----
dll/win32/browseui/CMakeLists.txt | 2 +-
dll/win32/msvcrt20/CMakeLists.txt | 2 +-
dll/win32/msvcrt40/CMakeLists.txt | 2 +-
hal/halx86/CMakeLists.txt | 2 +-
sdk/cmake/compilerflags.cmake | 41 -------------------------------------
sdk/cmake/gcc.cmake | 14 ++++++-------
sdk/cmake/msvc.cmake | 24 +++++++++++-----------
12 files changed, 34 insertions(+), 79 deletions(-)
diff --git a/base/setup/welcome/CMakeLists.txt b/base/setup/welcome/CMakeLists.txt
index 3ac8d946f4b..e5f2544e2c6 100644
--- a/base/setup/welcome/CMakeLists.txt
+++ b/base/setup/welcome/CMakeLists.txt
@@ -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()
diff --git a/boot/environ/CMakeLists.txt b/boot/environ/CMakeLists.txt
index bc4e21ee4a0..46d29015499 100644
--- a/boot/environ/CMakeLists.txt
+++ b/boot/environ/CMakeLists.txt
@@ -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)
diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt
index 678c20cafff..1746b7b8028 100644
--- a/boot/freeldr/freeldr/CMakeLists.txt
+++ b/boot/freeldr/freeldr/CMakeLists.txt
@@ -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)
diff --git a/dll/keyboard/CMakeLists.txt b/dll/keyboard/CMakeLists.txt
index 16d222a49b7..9401bde674a 100644
--- a/dll/keyboard/CMakeLists.txt
+++ b/dll/keyboard/CMakeLists.txt
@@ -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)
diff --git a/dll/ntdll/CMakeLists.txt b/dll/ntdll/CMakeLists.txt
index ce1a8fcc67b..be810e324f8 100644
--- a/dll/ntdll/CMakeLists.txt
+++ b/dll/ntdll/CMakeLists.txt
@@ -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)
diff --git a/dll/win32/browseui/CMakeLists.txt b/dll/win32/browseui/CMakeLists.txt
index 146ee786ca7..8b9eb4ebd3d 100644
--- a/dll/win32/browseui/CMakeLists.txt
+++ b/dll/win32/browseui/CMakeLists.txt
@@ -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()
diff --git a/dll/win32/msvcrt20/CMakeLists.txt b/dll/win32/msvcrt20/CMakeLists.txt
index 64ff8379c8b..8243cb18ce7 100644
--- a/dll/win32/msvcrt20/CMakeLists.txt
+++ b/dll/win32/msvcrt20/CMakeLists.txt
@@ -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)
diff --git a/dll/win32/msvcrt40/CMakeLists.txt b/dll/win32/msvcrt40/CMakeLists.txt
index e21c8d9f225..17dea15d6b7 100644
--- a/dll/win32/msvcrt40/CMakeLists.txt
+++ b/dll/win32/msvcrt40/CMakeLists.txt
@@ -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)
diff --git a/hal/halx86/CMakeLists.txt b/hal/halx86/CMakeLists.txt
index 77716ffa4c9..aaf526c11ea 100644
--- a/hal/halx86/CMakeLists.txt
+++ b/hal/halx86/CMakeLists.txt
@@ -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()
diff --git a/sdk/cmake/compilerflags.cmake b/sdk/cmake/compilerflags.cmake
index 3ebbc049e91..c569d5ddfbd 100644
--- a/sdk/cmake/compilerflags.cmake
+++ b/sdk/cmake/compilerflags.cmake
@@ -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()
diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake
index af04f616761..cb20227501d 100644
--- a/sdk/cmake/gcc.cmake
+++ b/sdk/cmake/gcc.cmake
@@ -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
diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake
index 139a886f30f..42776e416ce 100644
--- a/sdk/cmake/msvc.cmake
+++ b/sdk/cmake/msvc.cmake
@@ -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()