https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7d0cd6e9372501bf24c75…
commit 7d0cd6e9372501bf24c7540fd9bd48ea8614fe49
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Feb 10 00:43:31 2019 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Feb 10 00:43:31 2019 +0100
[FREELDR][SDK:CMAKE] Move the `MSVC "linker script" file' functionality
out of FreeLdr's cmake file and place it in the dedicated files instead.
---
boot/freeldr/freeldr/CMakeLists.txt | 68 -------------------------------------
sdk/cmake/gcc.cmake | 10 +++++-
sdk/cmake/msvc.cmake | 48 ++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 69 deletions(-)
diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt
index 6fb59604c2..74a9b444c2 100644
--- a/boot/freeldr/freeldr/CMakeLists.txt
+++ b/boot/freeldr/freeldr/CMakeLists.txt
@@ -5,74 +5,6 @@ if(SEPARATE_DBG)
set(CMAKE_LDR_PE_HELPER_STANDARD_LIBRARIES "-lgcc" CACHE STRING
"Standard C Libraries")
endif()
-if(NOT MSVC)
-###
-### For GCC
-###
-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}")
-
- # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
- # See also
http://www.cmake.org/pipermail/cmake/2010-May/037206.html
- add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
-endfunction()
-
-else()
-###
-### For MSVC
-###
-function(add_linker_script _target _linker_script_file)
- get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
- get_filename_component(_file_name ${_linker_script_file} NAME)
- set(_generated_file_path_prefix
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_target}.dir/${_file_name}")
-
- # Generate the ASM module containing sections specifications and layout.
- set(_generated_file "${_generated_file_path_prefix}.S")
- add_custom_command(
- OUTPUT ${_generated_file}
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${_file_full_path}" "${_generated_file}"
- DEPENDS ${_file_full_path})
- set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "ASM"
GENERATED TRUE)
- add_asm_files(${_target}_freeldr_linker_file ${_generated_file})
-
- # Generate the C module containing extra sections specifications and layout,
- # as well as comment-type linker #pragma directives.
- set(_generated_file "${_generated_file_path_prefix}.c")
- add_custom_command(
- OUTPUT ${_generated_file}
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${_file_full_path}" "${_generated_file}"
- DEPENDS ${_file_full_path})
- set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "C"
GENERATED TRUE)
- list(APPEND ${_target}_freeldr_linker_file ${_generated_file})
-
- # Add both files to the sources of the target.
- target_sources(${_target} PRIVATE "${${_target}_freeldr_linker_file}")
-
- # Create the additional linker response file.
- set(_generated_file "${_generated_file_path_prefix}.rsp")
- if(USE_CLANG_CL)
- set(_no_std_includes_flag "-nostdinc")
- else()
- set(_no_std_includes_flag "/X")
- endif()
- add_custom_command(
- #OUTPUT ${_generated_file}
- TARGET ${_target} PRE_LINK
- COMMAND ${CMAKE_C_COMPILER} /nologo ${_no_std_includes_flag} /D__LINKER__ /EP /c
"${_file_full_path}" > "${_generated_file}"
- DEPENDS ${_file_full_path}
- VERBATIM)
- set_source_files_properties(${_generated_file} PROPERTIES GENERATED TRUE)
- add_target_link_flags(${_target} "@${_generated_file}")
-
- # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
- # See also
http://www.cmake.org/pipermail/cmake/2010-May/037206.html
- add_target_property(${_target} LINK_DEPENDS ${_generated_file})
-endfunction()
-
-endif()
-
-
if(MSVC)
# We don't need hotpatching
replace_compile_flags("/hotpatch" " ")
diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake
index da203e5aa1..4c83f508f7 100644
--- a/sdk/cmake/gcc.cmake
+++ b/sdk/cmake/gcc.cmake
@@ -452,7 +452,6 @@ function(CreateBootSectorTarget _target_name _asm_file _binary_file
_base_addres
set_source_files_properties(${_object_file} ${_binary_file} PROPERTIES GENERATED
TRUE)
add_custom_target(${_target_name} ALL DEPENDS ${_binary_file})
-
endfunction()
function(allow_warnings __module)
@@ -463,3 +462,12 @@ endfunction()
macro(add_asm_files _target)
list(APPEND ${_target} ${ARGN})
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}")
+
+ # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
+ # See also
http://www.cmake.org/pipermail/cmake/2010-May/037206.html
+ add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
+endfunction()
diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake
index b0c5f18a45..7f0ec9851b 100644
--- a/sdk/cmake/msvc.cmake
+++ b/sdk/cmake/msvc.cmake
@@ -540,3 +540,51 @@ macro(add_asm_files _target)
list(APPEND ${_target} ${ARGN})
endif()
endmacro()
+
+function(add_linker_script _target _linker_script_file)
+ get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
+ get_filename_component(_file_name ${_linker_script_file} NAME)
+ set(_generated_file_path_prefix
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_target}.dir/${_file_name}")
+
+ # Generate the ASM module containing sections specifications and layout.
+ set(_generated_file "${_generated_file_path_prefix}.S")
+ add_custom_command(
+ OUTPUT ${_generated_file}
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${_file_full_path}" "${_generated_file}"
+ DEPENDS ${_file_full_path})
+ set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "ASM"
GENERATED TRUE)
+ add_asm_files(${_target}_linker_file ${_generated_file})
+
+ # Generate the C module containing extra sections specifications and layout,
+ # as well as comment-type linker #pragma directives.
+ set(_generated_file "${_generated_file_path_prefix}.c")
+ add_custom_command(
+ OUTPUT ${_generated_file}
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${_file_full_path}" "${_generated_file}"
+ DEPENDS ${_file_full_path})
+ set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "C"
GENERATED TRUE)
+ list(APPEND ${_target}_linker_file ${_generated_file})
+
+ # Add both files to the sources of the target.
+ target_sources(${_target} PRIVATE "${${_target}_linker_file}")
+
+ # Create the additional linker response file.
+ set(_generated_file "${_generated_file_path_prefix}.rsp")
+ if(USE_CLANG_CL)
+ set(_no_std_includes_flag "-nostdinc")
+ else()
+ set(_no_std_includes_flag "/X")
+ endif()
+ add_custom_command(
+ #OUTPUT ${_generated_file}
+ TARGET ${_target} PRE_LINK
+ COMMAND ${CMAKE_C_COMPILER} /nologo ${_no_std_includes_flag} /D__LINKER__ /EP /c
"${_file_full_path}" > "${_generated_file}"
+ DEPENDS ${_file_full_path}
+ VERBATIM)
+ set_source_files_properties(${_generated_file} PROPERTIES GENERATED TRUE)
+ add_target_link_flags(${_target} "@${_generated_file}")
+
+ # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
+ # See also
http://www.cmake.org/pipermail/cmake/2010-May/037206.html
+ add_target_property(${_target} LINK_DEPENDS ${_generated_file})
+endfunction()