1cmake_minimum_required(VERSION 3.5)
2
3set(XAAC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
4set(XAAC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
5
6if("${XAAC_ROOT}" STREQUAL "${XAAC_CONFIG_DIR}")
7  message(
8    FATAL_ERROR
9      "Building from within the libxaac 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(CMAKE_STATIC_LIBRARY_PREFIX "")
18
19if(SANITIZE)
20  string(TOLOWER ${SANITIZE} SANITIZE)
21
22  set(CMAKE_SANITIZER_C_FLAGS "-fno-omit-frame-pointer -fsanitize=${SANITIZE}")
23  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SANITIZER_C_FLAGS}")
24endif()
25
26list(
27  APPEND
28    LIBXAACDEC_SRCS
29    "${XAAC_ROOT}/decoder/ixheaacd_aacdecoder.c"
30    "${XAAC_ROOT}/decoder/ixheaacd_aacpluscheck.c"
31    "${XAAC_ROOT}/decoder/ixheaacd_aac_imdct.c"
32    "${XAAC_ROOT}/decoder/ixheaacd_aac_rom.c"
33    "${XAAC_ROOT}/decoder/ixheaacd_aac_tns.c"
34    "${XAAC_ROOT}/decoder/ixheaacd_acelp_bitparse.c"
35    "${XAAC_ROOT}/decoder/ixheaacd_acelp_decode.c"
36    "${XAAC_ROOT}/decoder/ixheaacd_acelp_mdct.c"
37    "${XAAC_ROOT}/decoder/ixheaacd_acelp_tools.c"
38    "${XAAC_ROOT}/decoder/ixheaacd_adts_crc_check.c"
39    "${XAAC_ROOT}/decoder/ixheaacd_api.c"
40    "${XAAC_ROOT}/decoder/ixheaacd_arith_dec.c"
41    "${XAAC_ROOT}/decoder/ixheaacd_avq_dec.c"
42    "${XAAC_ROOT}/decoder/ixheaacd_avq_rom.c"
43    "${XAAC_ROOT}/decoder/ixheaacd_basic_ops.c"
44    "${XAAC_ROOT}/decoder/ixheaacd_bitbuffer.c"
45    "${XAAC_ROOT}/decoder/ixheaacd_block.c"
46    "${XAAC_ROOT}/decoder/ixheaacd_channel.c"
47    "${XAAC_ROOT}/decoder/ixheaacd_common_initfuncs.c"
48    "${XAAC_ROOT}/decoder/ixheaacd_common_lpfuncs.c"
49    "${XAAC_ROOT}/decoder/ixheaacd_common_rom.c"
50    "${XAAC_ROOT}/decoder/ixheaacd_create.c"
51    "${XAAC_ROOT}/decoder/ixheaacd_decode_main.c"
52    "${XAAC_ROOT}/decoder/ixheaacd_dsp_fft32x32s.c"
53    "${XAAC_ROOT}/decoder/ixheaacd_env_calc.c"
54    "${XAAC_ROOT}/decoder/ixheaacd_env_dec.c"
55    "${XAAC_ROOT}/decoder/ixheaacd_env_extr.c"
56    "${XAAC_ROOT}/decoder/ixheaacd_esbr_envcal.c"
57    "${XAAC_ROOT}/decoder/ixheaacd_esbr_polyphase.c"
58    "${XAAC_ROOT}/decoder/ixheaacd_esbr_rom.c"
59    "${XAAC_ROOT}/decoder/ixheaacd_esbr_fft.c"
60    "${XAAC_ROOT}/decoder/ixheaacd_ext_ch_ele.c"
61    "${XAAC_ROOT}/decoder/ixheaacd_fft.c"
62    "${XAAC_ROOT}/decoder/ixheaacd_freq_sca.c"
63    "${XAAC_ROOT}/decoder/ixheaacd_fwd_alias_cnx.c"
64    "${XAAC_ROOT}/decoder/ixheaacd_hbe_trans.c"
65    "${XAAC_ROOT}/decoder/ixheaacd_headerdecode.c"
66    "${XAAC_ROOT}/decoder/ixheaacd_hufftables.c"
67    "${XAAC_ROOT}/decoder/ixheaacd_huff_tools.c"
68    "${XAAC_ROOT}/decoder/ixheaacd_hybrid.c"
69    "${XAAC_ROOT}/decoder/ixheaacd_imdct.c"
70    "${XAAC_ROOT}/decoder/ixheaacd_initfuncs.c"
71    "${XAAC_ROOT}/decoder/ixheaacd_init_config.c"
72    "${XAAC_ROOT}/decoder/ixheaacd_longblock.c"
73    "${XAAC_ROOT}/decoder/ixheaacd_lpc.c"
74    "${XAAC_ROOT}/decoder/ixheaacd_lpc_dec.c"
75    "${XAAC_ROOT}/decoder/ixheaacd_lpfuncs.c"
76    "${XAAC_ROOT}/decoder/ixheaacd_lpp_tran.c"
77    "${XAAC_ROOT}/decoder/ixheaacd_lt_predict.c"
78    "${XAAC_ROOT}/decoder/ixheaacd_mps_dec.c"
79    "${XAAC_ROOT}/decoder/ixheaacd_mps_decorr.c"
80    "${XAAC_ROOT}/decoder/ixheaacd_mps_hybrid_filt.c"
81    "${XAAC_ROOT}/decoder/ixheaacd_mps_parse.c"
82    "${XAAC_ROOT}/decoder/ixheaacd_mps_pre_mix.c"
83    "${XAAC_ROOT}/decoder/ixheaacd_mps_rom.c"
84    "${XAAC_ROOT}/decoder/ixheaacd_mps_smoothing.c"
85    "${XAAC_ROOT}/decoder/ixheaacd_mps_temp_process.c"
86    "${XAAC_ROOT}/decoder/ixheaacd_mps_temp_reshape.c"
87    "${XAAC_ROOT}/decoder/ixheaacd_pns_js_thumb.c"
88    "${XAAC_ROOT}/decoder/ixheaacd_pred_vec_block.c"
89    "${XAAC_ROOT}/decoder/ixheaacd_process.c"
90    "${XAAC_ROOT}/decoder/ixheaacd_ps_bitdec.c"
91    "${XAAC_ROOT}/decoder/ixheaacd_ps_dec.c"
92    "${XAAC_ROOT}/decoder/ixheaacd_pvc_rom.c"
93    "${XAAC_ROOT}/decoder/ixheaacd_rom.c"
94    "${XAAC_ROOT}/decoder/ixheaacd_sbrdecoder.c"
95    "${XAAC_ROOT}/decoder/ixheaacd_sbrdec_initfuncs.c"
96    "${XAAC_ROOT}/decoder/ixheaacd_sbrdec_lpfuncs.c"
97    "${XAAC_ROOT}/decoder/ixheaacd_sbr_crc.c"
98    "${XAAC_ROOT}/decoder/ixheaacd_sbr_dec.c"
99    "${XAAC_ROOT}/decoder/ixheaacd_sbr_rom.c"
100    "${XAAC_ROOT}/decoder/ixheaacd_spectrum_dec.c"
101    "${XAAC_ROOT}/decoder/ixheaacd_stereo.c"
102    "${XAAC_ROOT}/decoder/ixheaacd_tcx_fwd_alcnx.c"
103    "${XAAC_ROOT}/decoder/ixheaacd_tcx_fwd_mdct.c"
104    "${XAAC_ROOT}/decoder/ixheaacd_thumb_ps_dec.c"
105    "${XAAC_ROOT}/decoder/ixheaacd_tns.c"
106    "${XAAC_ROOT}/decoder/ixheaacd_basic_funcs.c"
107    "${XAAC_ROOT}/decoder/ixheaacd_Windowing.c"
108    "${XAAC_ROOT}/decoder/ixheaacd_latmdemux.c"
109    "${XAAC_ROOT}/decoder/ixheaacd_multichannel.c"
110    "${XAAC_ROOT}/decoder/ixheaacd_drc_freq_dec.c"
111    "${XAAC_ROOT}/decoder/ixheaacd_mps_poly_filt.c"
112    "${XAAC_ROOT}/decoder/ixheaacd_huff_code_reorder.c"
113    "${XAAC_ROOT}/decoder/ixheaacd_rev_vlc.c"
114    "${XAAC_ROOT}/decoder/ixheaacd_qmf_dec.c"
115    "${XAAC_ROOT}/decoder/drc_src/impd_drc_api.c"
116    "${XAAC_ROOT}/decoder/drc_src/impd_drc_bitbuffer.c"
117    "${XAAC_ROOT}/decoder/drc_src/impd_drc_dec.c"
118    "${XAAC_ROOT}/decoder/drc_src/impd_drc_dynamic_payload.c"
119    "${XAAC_ROOT}/decoder/drc_src/impd_drc_eq.c"
120    "${XAAC_ROOT}/decoder/drc_src/impd_drc_extr_delta_coded_info.c"
121    "${XAAC_ROOT}/decoder/drc_src/impd_drc_filter_bank.c"
122    "${XAAC_ROOT}/decoder/drc_src/impd_drc_gain_dec.c"
123    "${XAAC_ROOT}/decoder/drc_src/impd_drc_gain_decoder.c"
124    "${XAAC_ROOT}/decoder/drc_src/impd_drc_init.c"
125    "${XAAC_ROOT}/decoder/drc_src/impd_drc_interface_decoder.c"
126    "${XAAC_ROOT}/decoder/drc_src/impd_drc_loudness_control.c"
127    "${XAAC_ROOT}/decoder/drc_src/impd_drc_main_td_process.c"
128    "${XAAC_ROOT}/decoder/drc_src/impd_drc_multiband.c"
129    "${XAAC_ROOT}/decoder/drc_src/impd_drc_parametric_dec.c"
130    "${XAAC_ROOT}/decoder/drc_src/impd_drc_peak_limiter.c"
131    "${XAAC_ROOT}/decoder/drc_src/impd_drc_process.c"
132    "${XAAC_ROOT}/decoder/drc_src/impd_drc_rom.c"
133    "${XAAC_ROOT}/decoder/drc_src/impd_drc_selection_process.c"
134    "${XAAC_ROOT}/decoder/drc_src/impd_drc_selection_process_drcset_selection.c"
135    "${XAAC_ROOT}/decoder/drc_src/impd_drc_selection_process_init.c"
136    "${XAAC_ROOT}/decoder/drc_src/impd_drc_shape_filter.c"
137    "${XAAC_ROOT}/decoder/drc_src/impd_drc_static_payload.c")
138
139list(APPEND LIBXAACDEC_X86_SRCS
140            "${XAAC_ROOT}/decoder/generic/ixheaacd_qmf_dec_generic.c"
141            "${XAAC_ROOT}/decoder/x86/ixheaacd_function_selector_x86.c")
142
143set(LIBXAACDEC_INCLUDES ${XAAC_ROOT}/decoder ${XAAC_ROOT}/decoder/drc_src)
144
145set(LIBXAACDEC_C_FLAGS "${LIBXAACDEC_X86_C_FLAGS}")
146
147include_directories(${LIBXAACDEC_INCLUDES} ${LIBXAACDEC_X86_INCLUDES})
148add_library(libxaacdec ${LIBXAACDEC_SRCS} ${LIBXAACDEC_X86_SRCS})
149set_target_properties(libxaacdec
150                      PROPERTIES COMPILE_FLAGS "${LIBXAACDEC_C_FLAGS}")
151
152list(APPEND XAACDEC_SRCS
153            "${XAAC_ROOT}/test/ixheaacd_error.c"
154            "${XAAC_ROOT}/test/ixheaacd_fileifc.c"
155            "${XAAC_ROOT}/test/ixheaacd_main.c"
156            "${XAAC_ROOT}/test/ixheaacd_metadata_read.c")
157
158add_executable(xaacdec ${XAACDEC_SRCS})
159
160target_link_libraries(xaacdec libxaacdec m)
161set_target_properties(
162  xaacdec
163  PROPERTIES
164    COMPILE_FLAGS
165    "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DECLIPSE -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DENABLE_DRC"
166  )
167