diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d68ad183..7a73d72c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,33 +143,32 @@ MACRO(CHECK_SSE type flags) ENDMACRO() -CHECK_SSE("AVX" " ;-mavx;/arch:AVX") -CHECK_SSE("AVX2" " ;-mavx2 -mfma;/arch:AVX2") -CHECK_SSE("AVX512" " ;-mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma;/arch:AVX512") -CHECK_SSE("FMA" " ;-mfma;") - -IF(${AVX_FOUND}) - set(LLAMA_AVX ON) -ELSE() - set(LLAMA_AVX OFF) +IF(${LLAMA_AVX}) + CHECK_SSE("AVX" " ;-mavx;/arch:AVX") + IF(NOT ${AVX_FOUND}) + set(LLAMA_AVX OFF) + ENDIF() ENDIF() -IF (${FMA_FOUND}) - set(LLAMA_FMA ON) -ELSE() - set(LLAMA_FMA OFF) +IF(${LLAMA_AVX2}) + CHECK_SSE("AVX2" " ;-mavx2 -mfma;/arch:AVX2") + IF(NOT ${AVX2_FOUND}) + set(LLAMA_AVX2 OFF) + ENDIF() ENDIF() -IF(${AVX2_FOUND}) - set(LLAMA_AVX2 ON) -ELSE() - set(LLAMA_AVX2 OFF) +IF(${LLAMA_AVX512}) + CHECK_SSE("AVX512" " ;-mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma;/arch:AVX512") + IF(NOT ${AVX512_FOUND}) + set(LLAMA_AVX512 OFF) + ENDIF() ENDIF() -IF(${AVX512_FOUND}) - set(LLAMA_AVX512 ON) -ELSE() - set(LLAMA_AVX512 OFF) +IF(${LLAMA_FMA}) + CHECK_SSE("FMA" " ;-mfma;") + IF (NOT ${FMA_FOUND}) + set(LLAMA_FMA OFF) + ENDIF() ENDIF() #