1cmake_minimum_required(VERSION 3.5) 2 3set(MPEG2_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") 4set(MPEG2_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") 5 6if("${MPEG2_ROOT}" STREQUAL "${MPEG2_CONFIG_DIR}") 7 message( 8 FATAL_ERROR 9 "Building from within the libmpeg2 source tree is not supported.\n" 10 "Hint: Run these commands\n" 11 "$ rm -rf CMakeCache.txt CMakeFiles\n" 12 "$ mkdir -p ./build\n" 13 "$ cd ./build\n" 14 "And re-run CMake from the build directory.") 15endif() 16 17set(THREADS_PREFER_PTHREAD_FLAG ON) 18find_package(Threads REQUIRED) 19set(CMAKE_STATIC_LIBRARY_PREFIX "") 20 21if(SANITIZE) 22 string(TOLOWER ${SANITIZE} SANITIZE) 23 24 set(CMAKE_SANITIZER_C_FLAGS "-fno-omit-frame-pointer -fsanitize=${SANITIZE}") 25 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SANITIZER_C_FLAGS}") 26endif() 27 28list(APPEND LIBMPEG2DEC_SRCS 29 "${MPEG2_ROOT}/common/impeg2_buf_mgr.c" 30 "${MPEG2_ROOT}/common/impeg2_disp_mgr.c" 31 "${MPEG2_ROOT}/common/impeg2_format_conv.c" 32 "${MPEG2_ROOT}/common/impeg2_globals.c" 33 "${MPEG2_ROOT}/common/impeg2_idct.c" 34 "${MPEG2_ROOT}/common/impeg2_inter_pred.c" 35 "${MPEG2_ROOT}/common/impeg2_job_queue.c" 36 "${MPEG2_ROOT}/common/impeg2_mem_func.c" 37 "${MPEG2_ROOT}/common/ithread.c" 38 "${MPEG2_ROOT}/decoder/impeg2d_api_main.c" 39 "${MPEG2_ROOT}/decoder/impeg2d_bitstream.c" 40 "${MPEG2_ROOT}/decoder/impeg2d_debug.c" 41 "${MPEG2_ROOT}/decoder/impeg2d_dec_hdr.c" 42 "${MPEG2_ROOT}/decoder/impeg2d_decoder.c" 43 "${MPEG2_ROOT}/decoder/impeg2d_d_pic.c" 44 "${MPEG2_ROOT}/decoder/impeg2d_function_selector_generic.c" 45 "${MPEG2_ROOT}/decoder/impeg2d_globals.c" 46 "${MPEG2_ROOT}/decoder/impeg2d_i_pic.c" 47 "${MPEG2_ROOT}/decoder/impeg2d_mc.c" 48 "${MPEG2_ROOT}/decoder/impeg2d_mv_dec.c" 49 "${MPEG2_ROOT}/decoder/impeg2d_pic_proc.c" 50 "${MPEG2_ROOT}/decoder/impeg2d_pnb_pic.c" 51 "${MPEG2_ROOT}/decoder/impeg2d_vld.c" 52 "${MPEG2_ROOT}/decoder/impeg2d_vld_tables.c" 53 "${MPEG2_ROOT}/decoder/impeg2d_deinterlace.c" 54 "${MPEG2_ROOT}/common/icv_sad.c" 55 "${MPEG2_ROOT}/common/icv_variance.c" 56 "${MPEG2_ROOT}/common/ideint.c" 57 "${MPEG2_ROOT}/common/ideint_cac.c" 58 "${MPEG2_ROOT}/common/ideint_debug.c" 59 "${MPEG2_ROOT}/common/ideint_function_selector_generic.c" 60 "${MPEG2_ROOT}/common/ideint_utils.c") 61 62list(APPEND LIBMPEG2DEC_X86_SRCS 63 "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector.c" 64 "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector_avx2.c" 65 "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector_ssse3.c" 66 "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector_sse42.c" 67 "${MPEG2_ROOT}/common/x86/ideint_function_selector.c" 68 "${MPEG2_ROOT}/common/x86/ideint_function_selector_ssse3.c" 69 "${MPEG2_ROOT}/common/x86/ideint_function_selector_sse42.c" 70 "${MPEG2_ROOT}/common/x86/icv_variance_ssse3.c" 71 "${MPEG2_ROOT}/common/x86/icv_sad_ssse3.c" 72 "${MPEG2_ROOT}/common/x86/ideint_cac_ssse3.c" 73 "${MPEG2_ROOT}/common/x86/ideint_spatial_filter_ssse3.c" 74 "${MPEG2_ROOT}/common/x86/impeg2_idct_recon_sse42_intr.c" 75 "${MPEG2_ROOT}/common/x86/impeg2_inter_pred_sse42_intr.c" 76 "${MPEG2_ROOT}/common/x86/impeg2_mem_func_sse42_intr.c") 77 78set(LIBMPEG2DEC_INCLUDES ${MPEG2_ROOT}/common ${MPEG2_ROOT}/decoder) 79 80set(LIBMPEG2DEC_X86_C_FLAGS "-DX86 -DDISABLE_AVX2 -msse4.2 -mno-avx \ 81 -DDEFAULT_ARCH=D_ARCH_X86_SSE42 -DMULTICORE") 82set(LIBMPEG2DEC_X86_INCLUDES ${MPEG2_ROOT}/common/x86 ${MPEG2_ROOT}/decoder/x86) 83set(LIBMPEG2DEC_C_FLAGS "${LIBMPEG2DEC_X86_C_FLAGS}") 84 85include_directories(${LIBMPEG2DEC_INCLUDES} ${LIBMPEG2DEC_X86_INCLUDES}) 86add_library(libmpeg2dec ${LIBMPEG2DEC_SRCS} ${LIBMPEG2DEC_X86_SRCS}) 87set_target_properties(libmpeg2dec 88 PROPERTIES COMPILE_FLAGS "${LIBMPEG2DEC_C_FLAGS}") 89 90list(APPEND MPEG2DEC_SRCS "${MPEG2_ROOT}/test/decoder/main.c") 91 92add_executable(mpeg2dec ${MPEG2DEC_SRCS}) 93set_target_properties(mpeg2dec 94 PROPERTIES COMPILE_FLAGS "-DMD5_DISABLE -DPROFILE_ENABLE") 95target_link_libraries(mpeg2dec libmpeg2dec Threads::Threads) 96