cmake_minimum_required(VERSION 3.9.1) project(libmpeg2 C CXX) enable_language(ASM) set(MPEG2_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") set(MPEG2_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") if("${MPEG2_ROOT}" STREQUAL "${MPEG2_CONFIG_DIR}") message( FATAL_ERROR "Building from within the libmpeg2 source tree is not supported.\n" "Hint: Run these commands\n" "$ rm -rf CMakeCache.txt CMakeFiles\n" "$ mkdir -p ./build\n" "$ cd ./build\n" "And re-run CMake from the build directory.") endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) set(CMAKE_STATIC_LIBRARY_PREFIX "") include("${MPEG2_ROOT}/cmake/utils.cmake") libmpeg2_add_compile_options() libmpeg2_add_definitions() libmpeg2_set_link_libraries() list(APPEND LIBMPEG2DEC_SRCS "${MPEG2_ROOT}/common/impeg2_buf_mgr.c" "${MPEG2_ROOT}/common/impeg2_disp_mgr.c" "${MPEG2_ROOT}/common/impeg2_format_conv.c" "${MPEG2_ROOT}/common/impeg2_globals.c" "${MPEG2_ROOT}/common/impeg2_idct.c" "${MPEG2_ROOT}/common/impeg2_inter_pred.c" "${MPEG2_ROOT}/common/impeg2_job_queue.c" "${MPEG2_ROOT}/common/impeg2_mem_func.c" "${MPEG2_ROOT}/common/ithread.c" "${MPEG2_ROOT}/decoder/impeg2d_api_main.c" "${MPEG2_ROOT}/decoder/impeg2d_bitstream.c" "${MPEG2_ROOT}/decoder/impeg2d_debug.c" "${MPEG2_ROOT}/decoder/impeg2d_dec_hdr.c" "${MPEG2_ROOT}/decoder/impeg2d_decoder.c" "${MPEG2_ROOT}/decoder/impeg2d_d_pic.c" "${MPEG2_ROOT}/decoder/impeg2d_function_selector_generic.c" "${MPEG2_ROOT}/decoder/impeg2d_globals.c" "${MPEG2_ROOT}/decoder/impeg2d_i_pic.c" "${MPEG2_ROOT}/decoder/impeg2d_mc.c" "${MPEG2_ROOT}/decoder/impeg2d_mv_dec.c" "${MPEG2_ROOT}/decoder/impeg2d_pic_proc.c" "${MPEG2_ROOT}/decoder/impeg2d_pnb_pic.c" "${MPEG2_ROOT}/decoder/impeg2d_vld.c" "${MPEG2_ROOT}/decoder/impeg2d_vld_tables.c" "${MPEG2_ROOT}/decoder/impeg2d_deinterlace.c" "${MPEG2_ROOT}/common/icv_sad.c" "${MPEG2_ROOT}/common/icv_variance.c" "${MPEG2_ROOT}/common/ideint.c" "${MPEG2_ROOT}/common/ideint_cac.c" "${MPEG2_ROOT}/common/ideint_debug.c" "${MPEG2_ROOT}/common/ideint_function_selector_generic.c" "${MPEG2_ROOT}/common/ideint_utils.c") list(APPEND LIBMPEG2DEC_X86_SRCS "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector.c" "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector_avx2.c" "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector_ssse3.c" "${MPEG2_ROOT}/decoder/x86/impeg2d_function_selector_sse42.c" "${MPEG2_ROOT}/common/x86/ideint_function_selector.c" "${MPEG2_ROOT}/common/x86/ideint_function_selector_ssse3.c" "${MPEG2_ROOT}/common/x86/ideint_function_selector_sse42.c" "${MPEG2_ROOT}/common/x86/icv_variance_ssse3.c" "${MPEG2_ROOT}/common/x86/icv_sad_ssse3.c" "${MPEG2_ROOT}/common/x86/ideint_cac_ssse3.c" "${MPEG2_ROOT}/common/x86/ideint_spatial_filter_ssse3.c" "${MPEG2_ROOT}/common/x86/impeg2_idct_recon_sse42_intr.c" "${MPEG2_ROOT}/common/x86/impeg2_inter_pred_sse42_intr.c" "${MPEG2_ROOT}/common/x86/impeg2_mem_func_sse42_intr.c") set(LIBMPEG2DEC_INCLUDES ${MPEG2_ROOT}/common ${MPEG2_ROOT}/decoder) set(LIBMPEG2DEC_X86_C_FLAGS "-DX86 -DDISABLE_AVX2 -msse4.2 -mno-avx \ -DDEFAULT_ARCH=D_ARCH_X86_SSE42 -DMULTICORE") set(LIBMPEG2DEC_X86_INCLUDES ${MPEG2_ROOT}/common/x86 ${MPEG2_ROOT}/decoder/x86) set(LIBMPEG2DEC_C_FLAGS "${LIBMPEG2DEC_X86_C_FLAGS}") include_directories(${LIBMPEG2DEC_INCLUDES} ${LIBMPEG2DEC_X86_INCLUDES}) add_library(libmpeg2dec ${LIBMPEG2DEC_SRCS} ${LIBMPEG2DEC_X86_SRCS}) set_target_properties(libmpeg2dec PROPERTIES COMPILE_FLAGS "${LIBMPEG2DEC_C_FLAGS}") libmpeg2_add_executable(mpeg2dec libmpeg2dec SOURCES ${MPEG2_ROOT}/test/decoder/main.c) target_compile_definitions(mpeg2dec PRIVATE PROFILE_ENABLE MD5_DISABLE) libmpeg2_add_fuzzer(mpeg2_dec_fuzzer libmpeg2dec SOURCES ${MPEG2_ROOT}/fuzzer/mpeg2_dec_fuzzer.cpp)