cmake_minimum_required(VERSION 3.5)

project(sadl_codec LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-O3 -ffast-math -Wall -fstrict-aliasing -DNDEBUG=1  -Wno-unused-function")
file(GLOB SADL_FILES ../../sadl/sadl/*.h )

# note: model_cdfs.h and model_float/int16.h are generated by scripts and not included in the repository
include_directories(../../sadl)
include_directories(../../third_party/range_coder)
set(RANGE_CODER_FILES ../../third_party/range_coder/range_coder_impl.cpp ../../third_party/range_coder/range_coder_impl.h)
set(COMMON_FILES common.h model_cdfs.h range_coder.cpp range_coder.h ${RANGE_CODER_FILES}  ${SADL_FILES} )

set(DECODER_FILES  decoder_generic.h ${COMMON_FILES} )
set(ENCODER_FILES  encoder_generic.h ${COMMON_FILES} rdoq.h)

add_executable(decoder_sadl_float_generic decoder_float.h decoder_float.cpp ${DECODER_FILES})
add_executable(decoder_sadl_float_simd512 decoder_float.h decoder_float.cpp ${DECODER_FILES})

add_executable(encoder_sadl_float_simd512 encoder_float.cpp decoder_float.h ${ENCODER_FILES})
add_executable(encoder_sadl_float_generic encoder_float.cpp decoder_float.h ${ENCODER_FILES})

add_executable(extract_cdf extract_cdf.cpp )


target_link_libraries(encoder_sadl_float_simd512 pthread)
target_link_libraries(encoder_sadl_float_generic pthread)
# adjust SIMD level here: nothing: scalar, sse41, avx2, avx512, fma
set_target_properties(decoder_sadl_float_simd512 PROPERTIES COMPILE_FLAGS "-mavx512bw -mavx512f " )
set_target_properties(encoder_sadl_float_simd512 PROPERTIES COMPILE_FLAGS "-mavx512bw -mavx512f " )


# int16

add_executable(decoder_sadl_int16_generic decoder_int16.h decoder_int16.cpp ${DECODER_FILES})
add_executable(decoder_sadl_int16_simd512 decoder_int16.h decoder_int16.cpp ${DECODER_FILES})
add_executable(encoder_sadl_int16_simd512 encoder_int16.cpp decoder_int16.h ${ENCODER_FILES})
add_executable(encoder_sadl_int16_generic encoder_int16.cpp decoder_int16.h ${ENCODER_FILES})
target_link_libraries(encoder_sadl_int16_simd512 pthread)
target_link_libraries(encoder_sadl_int16_generic pthread)
set_target_properties(decoder_sadl_int16_simd512 PROPERTIES COMPILE_FLAGS "-mavx512bw -mavx512f " )
set_target_properties(encoder_sadl_int16_simd512 PROPERTIES COMPILE_FLAGS "-mavx512bw -mavx512f " )



