[CMAKE] Preprocess the ASM files but let msbuild handle their actual compilation

CORE-17423
This commit is contained in:
Jérôme Gardou 2021-01-22 11:28:11 +01:00 committed by Jérôme Gardou
parent 41130ab5c6
commit c68739e566
3 changed files with 27 additions and 38 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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()