1if(NOT DEFINED NASM) 2 set(NASM nasm CACHE PATH "Path to NASM/YASM executable") 3endif() 4 5if(SIMD_X86_64) 6 set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__) 7else() 8 if(BORLAND) 9 set(NAFLAGS -fobj -DOBJ32) 10 else() 11 set(NAFLAGS -fwin32 -DWIN32) 12 endif() 13endif() 14set(NAFLAGS ${NAFLAGS} -I${CMAKE_SOURCE_DIR}/win/ -I${CMAKE_CURRENT_SOURCE_DIR}/) 15 16# This only works if building from the command line. There is currently no way 17# to set a variable's value based on the build type when using the MSVC IDE. 18if(CMAKE_BUILD_TYPE STREQUAL "Debug" 19 OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") 20 set(NAFLAGS ${NAFLAGS} -g) 21endif() 22 23if(SIMD_X86_64) 24 set(SIMD_BASENAMES jfdctflt-sse-64 jccolor-sse2-64 jcgray-sse2-64 25 jcsample-sse2-64 jdcolor-sse2-64 jdmerge-sse2-64 jdsample-sse2-64 26 jfdctfst-sse2-64 jfdctint-sse2-64 jidctflt-sse2-64 jidctfst-sse2-64 27 jidctint-sse2-64 jidctred-sse2-64 jquantf-sse2-64 jquanti-sse2-64) 28 message(STATUS "Building x86_64 SIMD extensions") 29else() 30 set(SIMD_BASENAMES jsimdcpu jfdctflt-3dn jidctflt-3dn jquant-3dn jccolor-mmx 31 jcgray-mmx jcsample-mmx jdcolor-mmx jdmerge-mmx jdsample-mmx jfdctfst-mmx 32 jfdctint-mmx jidctfst-mmx jidctint-mmx jidctred-mmx jquant-mmx jfdctflt-sse 33 jidctflt-sse jquant-sse jccolor-sse2 jcgray-sse2 jcsample-sse2 jdcolor-sse2 34 jdmerge-sse2 jdsample-sse2 jfdctfst-sse2 jfdctint-sse2 jidctflt-sse2 35 jidctfst-sse2 jidctint-sse2 jidctred-sse2 jquantf-sse2 jquanti-sse2) 36 message(STATUS "Building i386 SIMD extensions") 37endif() 38 39if(MSVC_IDE) 40 set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") 41else() 42 set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR}) 43endif() 44 45file(GLOB INC_FILES *.inc) 46 47foreach(file ${SIMD_BASENAMES}) 48 set(DEPFILE "") 49 set(SIMD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${file}.asm) 50 if(${file} MATCHES jccolor) 51 set(DEPFILE ${file}) 52 string(REGEX REPLACE "jccolor" "jccolext" DEPFILE ${DEPFILE}) 53 set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm) 54 endif() 55 if(${file} MATCHES jcgray) 56 set(DEPFILE ${file}) 57 string(REGEX REPLACE "jcgray" "jcgryext" DEPFILE ${DEPFILE}) 58 set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm) 59 endif() 60 if(${file} MATCHES jdcolor) 61 set(DEPFILE ${file}) 62 string(REGEX REPLACE "jdcolor" "jdcolext" DEPFILE ${DEPFILE}) 63 set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm) 64 endif() 65 if(${file} MATCHES jdmerge) 66 set(DEPFILE ${file}) 67 string(REGEX REPLACE "jdmerge" "jdmrgext" DEPFILE ${DEPFILE}) 68 set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm) 69 endif() 70 set(SIMD_OBJ ${OBJDIR}/${file}.obj) 71 add_custom_command(OUTPUT ${SIMD_OBJ} 72 DEPENDS ${SIMD_SRC} ${DEPFILE} ${INC_FILES} 73 COMMAND ${NASM} ${NAFLAGS} ${SIMD_SRC} -o${SIMD_OBJ}) 74 set(SIMD_OBJS ${SIMD_OBJS} ${SIMD_OBJ}) 75endforeach() 76 77set(SIMD_OBJS ${SIMD_OBJS} PARENT_SCOPE) 78add_custom_target(simd DEPENDS ${SIMD_OBJS}) 79