cmake: only display the result of checking nasm once

if nasm is able to emit AVX512 instructions, we can assume that it's
able to generate AVX2 instructions as well. so no need to print "Found
nasm" multiple times.

and by chaining mutual exclusive branches with "elseif", we can have
better readability.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-01-04 01:15:54 +08:00
parent de78439775
commit d72c9205dc

View File

@ -26,7 +26,7 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp
ERROR_QUIET) ERROR_QUIET)
if(NOT rc) if(NOT rc)
set(${_support_x64_and_avx2} TRUE) set(${_support_x64_and_avx2} TRUE)
endif(NOT rc) endif()
execute_process(COMMAND nasm -D HAVE_AS_KNOWS_AVX512 -f ${object_format} execute_process(COMMAND nasm -D HAVE_AS_KNOWS_AVX512 -f ${object_format}
-i ${CMAKE_SOURCE_DIR}/src/isa-l/include/ -i ${CMAKE_SOURCE_DIR}/src/isa-l/include/
${CMAKE_SOURCE_DIR}/src/isa-l/erasure_code/gf_vect_dot_prod_avx512.asm ${CMAKE_SOURCE_DIR}/src/isa-l/erasure_code/gf_vect_dot_prod_avx512.asm
@ -36,7 +36,7 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp
ERROR_QUIET) ERROR_QUIET)
if(NOT rt) if(NOT rt)
set(${_support_x64_and_avx512} TRUE) set(${_support_x64_and_avx512} TRUE)
endif(NOT rt) endif()
endif(${_support_x64}) endif(${_support_x64})
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64") endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
endif(NOT no_nasm) endif(NOT no_nasm)
@ -44,14 +44,11 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp
message(STATUS "Could NOT find nasm") message(STATUS "Could NOT find nasm")
elseif(NOT ${_support_x64}) elseif(NOT ${_support_x64})
message(STATUS "Found nasm: but x86_64 with x32 ABI is not supported") message(STATUS "Found nasm: but x86_64 with x32 ABI is not supported")
endif() elseif(${_support_x64_and_avx512})
if(${_support_x64_and_avx512})
message(STATUS "Found nasm: best -- capable of assembling AVX512") message(STATUS "Found nasm: best -- capable of assembling AVX512")
endif() elseif(${_support_x64_and_avx2})
if(${_support_x64_and_avx2})
message(STATUS "Found nasm: better -- capable of assembling AVX2") message(STATUS "Found nasm: better -- capable of assembling AVX2")
endif() elseif(${_support_x64})
if(${_support_x64})
message(STATUS "Found nasm: good -- capable of assembling x86_64") message(STATUS "Found nasm: good -- capable of assembling x86_64")
endif() endif()
endmacro() endmacro()