https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c68739e56610c5e7877e3…
commit c68739e56610c5e7877e313662b178bec79437a8
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Jan 22 11:28:11 2021 +0100
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Mar 3 08:34:32 2021 +0100
[CMAKE] Preprocess the ASM files but let msbuild handle their actual compilation
CORE-17423
---
CMakeLists.txt | 1 -
sdk/cmake/msvc.cmake | 62 +++++++++++++++++++++-------------------------------
toolchain-msvc.cmake | 2 ++
3 files changed, 27 insertions(+), 38 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 99488e38702..d090b2f79c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -214,7 +214,6 @@ Enable this if the module uses typeid or dynamic_cast. You will
probably need to
# Activate support for assembly source files
if (MSVC)
- set(CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS s;S)
enable_language(ASM_MASM)
else()
enable_language(ASM)
diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake
index abd935821a4..33fdbea00f0 100644
--- a/sdk/cmake/msvc.cmake
+++ b/sdk/cmake/msvc.cmake
@@ -189,14 +189,13 @@ else()
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> /nologo <INCLUDES>
<FLAGS> <DEFINES> ${I18N_DEFS} /fo <OBJECT> <SOURCE>")
endif()
-if(ARCH STREQUAL "arm")
- set(CMAKE_ASM_MASM_COMPILE_OBJECT
- "cl ${cl_includes_flag} /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm
/I${REACTOS_BINARY_DIR}/sdk/include/asm <INCLUDES> <FLAGS> <DEFINES>
/D__ASM__ /D_USE_ML /EP /c <SOURCE> > <OBJECT>.tmp"
- "<CMAKE_ASM_MASM_COMPILER> -nologo -o <OBJECT>
<OBJECT>.tmp")
-else()
- set(CMAKE_ASM_MASM_COMPILE_OBJECT
- "cl ${cl_includes_flag} /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm
/I${REACTOS_BINARY_DIR}/sdk/include/asm <INCLUDES> <FLAGS> <DEFINES>
/D__ASM__ /D_USE_ML /EP /c <SOURCE> > <OBJECT>.tmp"
- "<CMAKE_ASM_MASM_COMPILER> /nologo /Cp /Fo<OBJECT> /c /Ta
<OBJECT>.tmp")
+# We don't put <INCLUDES> <DEFINES> <FLAGS> because this is handled
in add_asm_files macro
+if (NOT MSVC_IDE)
+ if(ARCH STREQUAL "arm")
+ set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> -nologo
-o <OBJECT> <SOURCE>")
+ else()
+ set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> /nologo
/Cp /Fo <OBJECT> /c /Ta <SOURCE>")
+ endif()
endif()
if(_VS_ANALYZE_)
@@ -437,37 +436,26 @@ function(allow_warnings __module)
endfunction()
macro(add_asm_files _target)
- if(MSVC_IDE)
- get_defines(_directory_defines)
- get_includes(_directory_includes)
- get_directory_property(_defines COMPILE_DEFINITIONS)
- foreach(_source_file ${ARGN})
- get_filename_component(_source_file_base_name ${_source_file} NAME_WE)
- get_filename_component(_source_file_full_path ${_source_file} ABSOLUTE)
- set(_preprocessed_asm_file
${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.tmp)
- set(_object_file
${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.obj)
- get_source_file_property(_defines_semicolon_list ${_source_file_full_path}
COMPILE_DEFINITIONS)
- unset(_source_file_defines)
- foreach(_define ${_defines_semicolon_list})
- if(NOT ${_define} STREQUAL "NOTFOUND")
- list(APPEND _source_file_defines -D${_define})
- endif()
- endforeach()
- if(ARCH STREQUAL "arm")
- set(_pp_asm_compile_command ${CMAKE_ASM_MASM_COMPILER} -nologo -o
${_object_file} ${_preprocessed_asm_file})
- else()
- set(_pp_asm_compile_command ${CMAKE_ASM_MASM_COMPILER} /nologo /Cp
/Fo${_object_file} /c /Ta ${_preprocessed_asm_file})
+ get_defines(_directory_defines)
+ get_includes(_directory_includes)
+ get_directory_property(_defines COMPILE_DEFINITIONS)
+ foreach(_source_file ${ARGN})
+ get_filename_component(_source_file_base_name ${_source_file} NAME_WE)
+ get_filename_component(_source_file_full_path ${_source_file} ABSOLUTE)
+ set(_preprocessed_asm_file
${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.asm)
+ get_source_file_property(_defines_semicolon_list ${_source_file_full_path}
COMPILE_DEFINITIONS)
+ unset(_source_file_defines)
+ foreach(_define ${_defines_semicolon_list})
+ if(NOT ${_define} STREQUAL "NOTFOUND")
+ list(APPEND _source_file_defines -D${_define})
endif()
- add_custom_command(
- OUTPUT ${_preprocessed_asm_file} ${_object_file}
- COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm
/I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines}
${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} >
${_preprocessed_asm_file} && ${_pp_asm_compile_command}
- DEPENDS ${_source_file_full_path})
- set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT TRUE)
- list(APPEND ${_target} ${_object_file})
endforeach()
- else()
- list(APPEND ${_target} ${ARGN})
- endif()
+ add_custom_command(
+ OUTPUT ${_preprocessed_asm_file}
+ COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm
/I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines}
${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} >
${_preprocessed_asm_file}
+ DEPENDS ${_source_file_full_path})
+ list(APPEND ${_target} ${_preprocessed_asm_file})
+ endforeach()
endmacro()
function(add_linker_script _target _linker_script_file)
diff --git a/toolchain-msvc.cmake b/toolchain-msvc.cmake
index bde0f0ae6a7..dbb901ae874 100644
--- a/toolchain-msvc.cmake
+++ b/toolchain-msvc.cmake
@@ -54,12 +54,14 @@ set(CMAKE_MC_COMPILER mc)
set(CMAKE_RC_COMPILER rc)
if(ARCH STREQUAL "amd64")
set(CMAKE_ASM_MASM_COMPILER ml64)
+ set(CMAKE_ASM_MASM_FLAGS_INIT "/Cp")
elseif(ARCH STREQUAL "arm")
set(CMAKE_ASM_MASM_COMPILER armasm)
elseif(ARCH STREQUAL "arm64")
set(CMAKE_ASM_MASM_COMPILER armasm64)
else()
set(CMAKE_ASM_MASM_COMPILER ml)
+ set(CMAKE_ASM_MASM_FLAGS_INIT "/Cp")
endif()