Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.1) |
| 2 | |
| 3 | include(opus_functions.cmake) |
| 4 | |
| 5 | get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) |
| 6 | message(STATUS "Opus library version: ${OPUS_LIBRARY_VERSION}") |
| 7 | |
| 8 | get_package_version(PACKAGE_VERSION) |
| 9 | message(STATUS "Opus package version: ${PACKAGE_VERSION}") |
| 10 | |
| 11 | string(REGEX |
| 12 | REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*" |
| 13 | "\\1" |
| 14 | PROJECT_VERSION |
| 15 | ${PACKAGE_VERSION}) |
| 16 | message(STATUS "Opus project version: ${PROJECT_VERSION}") |
| 17 | |
| 18 | project(Opus LANGUAGES C VERSION ${PROJECT_VERSION}) |
Marcus Asteborg | 1f92613 | 2019-04-11 09:50:14 -0700 | [diff] [blame] | 19 | include(opus_buildtype.cmake) |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 20 | |
Davide Beatrici | c487f53 | 2019-10-01 06:08:04 +0200 | [diff] [blame] | 21 | option(OPUS_BUILD_SHARED_LIBRARY "Build shared library" OFF) |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 22 | option(OPUS_STACK_PROTECTOR "Use stack protection" ON) |
| 23 | option(OPUS_USE_ALLOCA "Use alloca for stack arrays (on non-C99 compilers)" OFF) |
| 24 | option(OPUS_CUSTOM_MODES "Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames" |
| 25 | OFF) |
| 26 | option(OPUS_BUILD_PROGRAMS "Build programs" OFF) |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 27 | option(OPUS_FIXED_POINT |
| 28 | "Compile as fixed-point (for machines without a fast enough FPU)" OFF) |
| 29 | option(OPUS_ENABLE_FLOAT_API |
| 30 | "Compile with the floating point API (for machines with float library" |
| 31 | ON) |
| 32 | option(OPUS_INSTALL_PKG_CONFIG_MODULE "Install PkgConfig module" ON) |
| 33 | option(OPUS_INSTALL_CMAKE_CONFIG_MODULE "Install CMake package config module" |
| 34 | ON) |
| 35 | |
| 36 | include(opus_config.cmake) |
| 37 | include(opus_sources.cmake) |
| 38 | include(GNUInstallDirs) |
| 39 | include(CMakeDependentOption) |
| 40 | include(FeatureSummary) |
| 41 | |
Marcus Asteborg | 965a72e | 2019-12-17 10:21:21 -0800 | [diff] [blame] | 42 | if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS) |
Davide Beatrici | c487f53 | 2019-10-01 06:08:04 +0200 | [diff] [blame] | 43 | # Global flag to cause add_library() to create shared libraries if on. |
| 44 | set(BUILD_SHARED_LIBS ON) |
Marcus Asteborg | 965a72e | 2019-12-17 10:21:21 -0800 | [diff] [blame] | 45 | set(OPUS_BUILD_SHARED_LIBRARY ON) |
Davide Beatrici | c487f53 | 2019-10-01 06:08:04 +0200 | [diff] [blame] | 46 | endif() |
| 47 | |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 48 | if(OPUS_STACK_PROTECTOR) |
| 49 | if(NOT MSVC) # GC on by default on MSVC |
| 50 | check_and_set_flag(STACK_PROTECTION_STRONG -fstack-protector-strong) |
| 51 | endif() |
| 52 | else() |
| 53 | if(MSVC) |
| 54 | check_and_set_flag(BUFFER_SECURITY_CHECK /GS-) |
| 55 | endif() |
| 56 | endif() |
| 57 | |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 58 | if(OPUS_CPU_X86 OR OPUS_CPU_X64) |
| 59 | cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE |
| 60 | "Does runtime check for SSE1 support" |
| 61 | ON |
| 62 | "SSE1_SUPPORTED" |
| 63 | OFF) |
| 64 | cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2 |
| 65 | "Does runtime check for SSE2 support" |
| 66 | ON |
| 67 | "SSE2_SUPPORTED" |
| 68 | OFF) |
| 69 | cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE4_1 |
| 70 | "Does runtime check for SSE4.1 support" |
| 71 | ON |
| 72 | "SSE4_1_SUPPORTED" |
| 73 | OFF) |
| 74 | cmake_dependent_option(OPUS_X86_MAY_HAVE_AVX |
| 75 | "Does runtime check for AVX support" |
| 76 | ON |
| 77 | "AVX_SUPPORTED" |
| 78 | OFF) |
| 79 | |
| 80 | if(OPUS_CPU_X64) # Assume 64 bit has SSE2 support |
| 81 | cmake_dependent_option(OPUS_X86_PRESUME_SSE |
| 82 | "Assume target CPU has SSE1 support" |
| 83 | ON |
| 84 | "OPUS_X86_MAY_HAVE_SSE" |
| 85 | OFF) |
| 86 | cmake_dependent_option(OPUS_X86_PRESUME_SSE2 |
| 87 | "Assume target CPU has SSE2 support" |
| 88 | ON |
| 89 | "OPUS_X86_MAY_HAVE_SSE2" |
| 90 | OFF) |
| 91 | else() |
| 92 | cmake_dependent_option(OPUS_X86_PRESUME_SSE |
| 93 | "Assume target CPU has SSE1 support" |
| 94 | OFF |
| 95 | "OPUS_X86_MAY_HAVE_SSE" |
| 96 | OFF) |
| 97 | cmake_dependent_option(OPUS_X86_PRESUME_SSE2 |
| 98 | "Assume target CPU has SSE2 support" |
| 99 | OFF |
| 100 | "OPUS_X86_MAY_HAVE_SSE2" |
| 101 | OFF) |
| 102 | endif() |
| 103 | cmake_dependent_option(OPUS_X86_PRESUME_SSE4_1 |
| 104 | "Assume target CPU has SSE4.1 support" |
| 105 | OFF |
| 106 | "OPUS_X86_MAY_HAVE_SSE4_1" |
| 107 | OFF) |
| 108 | cmake_dependent_option(OPUS_X86_PRESUME_AVX |
| 109 | "Assume target CPU has AVX support" |
| 110 | OFF |
| 111 | "OPUS_X86_MAY_HAVE_AVX" |
| 112 | OFF) |
| 113 | endif() |
| 114 | |
| 115 | set_package_properties(Git |
| 116 | PROPERTIES |
| 117 | TYPE |
| 118 | REQUIRED |
| 119 | DESCRIPTION |
| 120 | "fast, scalable, distributed revision control system" |
| 121 | URL |
| 122 | "https://git-scm.com/" |
| 123 | PURPOSE |
| 124 | "required to set up package version") |
| 125 | |
Marcus Asteborg | 965a72e | 2019-12-17 10:21:21 -0800 | [diff] [blame] | 126 | add_feature_info(BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY "Build shared library") |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 127 | add_feature_info(STACK_PROTECTOR OPUS_STACK_PROTECTOR "Use stack protection") |
| 128 | add_feature_info(USE_ALLOCA OPUS_USE_ALLOCA |
| 129 | "Use alloca for stack arrays (on non-C99 compilers)") |
| 130 | add_feature_info(CUSTOM_MODES OPUS_CUSTOM_MODES |
| 131 | "Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames") |
| 132 | add_feature_info(BUILD_PROGRAMS OPUS_BUILD_PROGRAMS "Build programs") |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 133 | add_feature_info( |
| 134 | FIXED_POINT OPUS_FIXED_POINT |
| 135 | "compile as fixed-point (for machines without a fast enough FPU)") |
| 136 | add_feature_info( |
| 137 | FLOAT_API OPUS_ENABLE_FLOAT_API |
| 138 | "compile with the floating point API (for machines with float library)") |
| 139 | |
| 140 | add_feature_info(INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE |
| 141 | "install PkgConfig module") |
| 142 | add_feature_info(INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE |
| 143 | "install CMake package config module") |
| 144 | |
| 145 | if(OPUS_CPU_X86 OR OPUS_CPU_X64) |
| 146 | add_feature_info(X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE |
| 147 | "does runtime check for SSE1 support") |
| 148 | add_feature_info(X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2 |
| 149 | "does runtime check for SSE2 support") |
| 150 | add_feature_info(X86_MAY_HAVE_SSE4_1 OPUS_X86_MAY_HAVE_SSE4_1 |
| 151 | "does runtime check for SSE4_1 support") |
| 152 | add_feature_info(X86_MAY_HAVE_AVX OPUS_X86_MAY_HAVE_AVX |
| 153 | "does runtime check for AVX support") |
| 154 | add_feature_info(X86_PRESUME_SSE OPUS_X86_PRESUME_SSE |
| 155 | "assume target CPU has SSE1 support") |
| 156 | add_feature_info(X86_PRESUME_SSE2 OPUS_X86_PRESUME_SSE2 |
| 157 | "assume target CPU has SSE2 support") |
| 158 | add_feature_info(X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1 |
| 159 | "assume target CPU has SSE4_1 support") |
| 160 | add_feature_info(X86_PRESUME_AVX OPUS_X86_PRESUME_AVX |
| 161 | "assume target CPU has AVX support") |
| 162 | endif() |
| 163 | |
| 164 | feature_summary(WHAT ALL) |
| 165 | |
| 166 | add_library(opus ${opus_sources} ${opus_sources_float}) |
| 167 | |
Nathaniel R. Lewis | 60472f2 | 2019-05-08 21:51:22 -0700 | [diff] [blame^] | 168 | add_library(Opus::opus ALIAS opus) |
| 169 | |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 170 | set(Opus_PUBLIC_HEADER |
| 171 | ${CMAKE_CURRENT_SOURCE_DIR}/include/opus.h |
| 172 | ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h |
| 173 | ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_defines.h |
| 174 | ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_multistream.h |
| 175 | ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_projection.h |
| 176 | ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_types.h) |
| 177 | |
| 178 | set_target_properties(opus |
| 179 | PROPERTIES SOVERSION |
| 180 | ${OPUS_LIBRARY_VERSION_MAJOR} |
| 181 | VERSION |
| 182 | ${OPUS_LIBRARY_VERSION} |
| 183 | PUBLIC_HEADER |
| 184 | "${Opus_PUBLIC_HEADER}") |
| 185 | |
| 186 | target_include_directories( |
| 187 | opus |
| 188 | PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 189 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
| 190 | PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 191 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 192 | celt |
| 193 | silk) |
| 194 | |
| 195 | target_link_libraries(opus PRIVATE ${OPUS_REQUIRED_LIBRARIES}) |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 196 | target_compile_definitions(opus PRIVATE OPUS_BUILD ENABLE_HARDENING) |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 197 | |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 198 | if(NOT MSVC) |
Marcus Asteborg | ad8fe90 | 2019-04-23 13:41:14 -0700 | [diff] [blame] | 199 | target_compile_definitions(opus PRIVATE _FORTIFY_SOURCE=2) |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 200 | endif() |
| 201 | |
| 202 | # It is strongly recommended to uncomment one of these VAR_ARRAYS: Use C99 |
| 203 | # variable-length arrays for stack allocation USE_ALLOCA: Use alloca() for stack |
| 204 | # allocation If none is defined, then the fallback is a non-threadsafe global |
| 205 | # array |
| 206 | if(OPUS_USE_ALLOCA OR MSVC) |
| 207 | target_compile_definitions(opus PRIVATE USE_ALLOCA) |
| 208 | else() |
| 209 | target_compile_definitions(opus PRIVATE VAR_ARRAYS) |
| 210 | endif() |
| 211 | |
| 212 | if(OPUS_CUSTOM_MODES) |
| 213 | target_compile_definitions(opus PRIVATE CUSTOM_MODES) |
| 214 | endif() |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 215 | |
| 216 | if(BUILD_SHARED_LIBS) |
| 217 | if(WIN32) |
| 218 | target_compile_definitions(opus PRIVATE DLL_EXPORT) |
| 219 | else() |
| 220 | include(CheckCCompilerFlag) |
| 221 | check_c_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) |
| 222 | if(COMPILER_HAS_HIDDEN_VISIBILITY) |
| 223 | set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden) |
| 224 | endif() |
| 225 | endif() |
| 226 | endif() |
| 227 | |
| 228 | add_sources_group(opus silk ${silk_sources}) |
| 229 | add_sources_group(opus celt ${celt_sources}) |
| 230 | |
| 231 | if(OPUS_FIXED_POINT) |
| 232 | add_sources_group(opus silk ${silk_sources_fixed}) |
| 233 | target_include_directories(opus PRIVATE silk/fixed) |
| 234 | target_compile_definitions(opus PRIVATE FIXED_POINT=1) |
| 235 | else() |
| 236 | add_sources_group(opus silk ${silk_sources_float}) |
| 237 | target_include_directories(opus PRIVATE silk/float) |
| 238 | endif() |
| 239 | |
| 240 | if(NOT OPUS_ENABLE_FLOAT_API) |
| 241 | target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API) |
| 242 | endif() |
| 243 | |
| 244 | if(OPUS_X86_MAY_HAVE_SSE |
| 245 | OR OPUS_X86_MAY_HAVE_SSE2 |
| 246 | OR OPUS_X86_MAY_HAVE_SSE4_1 |
| 247 | OR OPUS_X86_MAY_HAVE_AVX) |
| 248 | target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) |
| 249 | endif() |
| 250 | |
| 251 | if(OPUS_X86_MAY_HAVE_SSE) |
| 252 | add_sources_group(opus celt ${celt_sources_sse}) |
| 253 | target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE) |
| 254 | endif() |
| 255 | if(OPUS_X86_PRESUME_SSE) |
| 256 | target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE) |
| 257 | endif() |
| 258 | |
| 259 | if(OPUS_X86_MAY_HAVE_SSE2) |
| 260 | add_sources_group(opus celt ${celt_sources_sse2}) |
| 261 | target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2) |
| 262 | endif() |
| 263 | if(OPUS_X86_PRESUME_SSE2) |
| 264 | target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2) |
| 265 | endif() |
| 266 | |
| 267 | if(OPUS_X86_MAY_HAVE_SSE) |
| 268 | add_sources_group(opus celt ${celt_sources_sse4_1}) |
| 269 | add_sources_group(opus silk ${silk_sources_sse4_1}) |
| 270 | if(OPUS_FIXED_POINT) |
| 271 | add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) |
| 272 | endif() |
| 273 | target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) |
| 274 | endif() |
| 275 | if(OPUS_X86_PRESUME_SSE4_1) |
| 276 | target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) |
| 277 | endif() |
| 278 | |
| 279 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "(armv7-a)") |
| 280 | add_sources_group(opus celt ${celt_sources_arm}) |
| 281 | endif() |
| 282 | |
| 283 | if(COMPILER_SUPPORT_NEON AND OPUS_USE_NEON) |
| 284 | |
| 285 | if(OPUS_MAY_HAVE_NEON) |
| 286 | if(RUNTIME_CPU_CAPABILITY_DETECTION) |
| 287 | message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection") |
| 288 | target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) |
| 289 | else() |
| 290 | message(ERROR "Runtime cpu capability detection needed for MAY_HAVE_NEON") |
| 291 | endif() |
| 292 | # Do runtime check for NEON |
| 293 | target_compile_definitions(opus |
| 294 | PRIVATE |
| 295 | OPUS_ARM_MAY_HAVE_NEON |
| 296 | OPUS_ARM_MAY_HAVE_NEON_INTR) |
| 297 | endif() |
| 298 | |
| 299 | add_sources_group(opus celt ${celt_sources_arm_neon_intr}) |
| 300 | add_sources_group(opus silk ${silk_sources_arm_neon_intr}) |
| 301 | |
| 302 | # silk arm neon depends on main_Fix.h |
| 303 | target_include_directories(opus PRIVATE silk/fixed) |
| 304 | |
| 305 | if(OPUS_FIXED_POINT) |
| 306 | add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr}) |
| 307 | endif() |
| 308 | |
| 309 | if(OPUS_PRESUME_NEON) |
| 310 | target_compile_definitions(opus |
| 311 | PRIVATE |
| 312 | OPUS_ARM_PRESUME_NEON |
| 313 | OPUS_ARM_PRESUME_NEON_INTR) |
| 314 | endif() |
| 315 | endif() |
| 316 | |
| 317 | install(TARGETS opus |
| 318 | EXPORT OpusTargets |
| 319 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 320 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 321 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 322 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/opus) |
| 323 | |
| 324 | if(OPUS_INSTALL_PKG_CONFIG_MODULE) |
| 325 | set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 326 | set(exec_prefix ${CMAKE_INSTALL_PREFIX}) |
| 327 | set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) |
| 328 | set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) |
| 329 | set(VERSION ${OPUS_LIBRARY_VERSION}) |
| 330 | set(VERSION ${OPUS_LIBRARY_VERSION}) |
| 331 | if(HAVE_LIBM) |
| 332 | set(LIBM "-lm") |
| 333 | endif() |
| 334 | configure_file(opus.pc.in opus.pc) |
| 335 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opus.pc |
| 336 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
| 337 | endif() |
| 338 | |
| 339 | if(OPUS_INSTALL_CMAKE_CONFIG_MODULE) |
| 340 | set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) |
| 341 | install(EXPORT OpusTargets |
| 342 | NAMESPACE Opus:: |
| 343 | DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) |
| 344 | |
| 345 | include(CMakePackageConfigHelpers) |
| 346 | |
| 347 | set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) |
| 348 | configure_package_config_file(OpusConfig.cmake.in |
| 349 | OpusConfig.cmake |
| 350 | INSTALL_DESTINATION |
| 351 | ${CMAKE_INSTALL_PACKAGEDIR} |
| 352 | PATH_VARS |
| 353 | INCLUDE_INSTALL_DIR |
| 354 | INSTALL_PREFIX |
| 355 | ${CMAKE_INSTALL_PREFIX}) |
| 356 | write_basic_package_version_file(OpusConfigVersion.cmake |
| 357 | VERSION ${PROJECT_VERSION} |
| 358 | COMPATIBILITY SameMajorVersion) |
| 359 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpusConfig.cmake |
| 360 | ${CMAKE_CURRENT_BINARY_DIR}/OpusConfigVersion.cmake |
| 361 | DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) |
| 362 | endif() |
| 363 | |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 364 | if(OPUS_BUILD_PROGRAMS) |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 365 | # demo |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 366 | if(OPUS_CUSTOM_MODES) |
| 367 | add_executable(opus_custom_demo ${opus_custom_demo_sources}) |
| 368 | target_include_directories(opus_custom_demo |
| 369 | PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 370 | target_link_libraries(opus_custom_demo PRIVATE opus) |
| 371 | endif() |
| 372 | |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 373 | add_executable(opus_demo ${opus_demo_sources}) |
| 374 | target_include_directories(opus_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
Marcus Asteborg | 268780f | 2019-04-10 16:34:01 -0700 | [diff] [blame] | 375 | target_include_directories(opus_demo PRIVATE silk) # debug.h |
| 376 | target_include_directories(opus_demo PRIVATE celt) # arch.h |
Marcus Asteborg | f9d3d43 | 2018-11-15 19:48:38 -0800 | [diff] [blame] | 377 | target_link_libraries(opus_demo PRIVATE opus) |
| 378 | |
| 379 | # compare |
| 380 | add_executable(opus_compare ${opus_compare_sources}) |
| 381 | target_include_directories(opus_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 382 | target_link_libraries(opus_compare PRIVATE opus) |
| 383 | endif() |
| 384 | |
| 385 | if(BUILD_TESTING) |
| 386 | enable_testing() |
| 387 | |
| 388 | # tests |
| 389 | add_executable(test_opus_decode ${test_opus_decode_sources}) |
| 390 | target_include_directories(test_opus_decode |
| 391 | PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 392 | target_link_libraries(test_opus_decode PRIVATE opus) |
| 393 | if(OPUS_FIXED_POINT) |
| 394 | target_compile_definitions(test_opus_decode PRIVATE DISABLE_FLOAT_API) |
| 395 | endif() |
| 396 | add_test(test_opus_decode test_opus_decode) |
| 397 | |
| 398 | add_executable(test_opus_padding ${test_opus_padding_sources}) |
| 399 | target_include_directories(test_opus_padding |
| 400 | PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 401 | target_link_libraries(test_opus_padding PRIVATE opus) |
| 402 | add_test(test_opus_padding test_opus_padding) |
| 403 | |
| 404 | if(NOT BUILD_SHARED_LIBS) |
| 405 | # disable tests that depends on private API when building shared lib |
| 406 | add_executable(test_opus_api ${test_opus_api_sources}) |
| 407 | target_include_directories(test_opus_api |
| 408 | PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt) |
| 409 | target_link_libraries(test_opus_api PRIVATE opus) |
| 410 | if(OPUS_FIXED_POINT) |
| 411 | target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API) |
| 412 | endif() |
| 413 | add_test(test_opus_api test_opus_api) |
| 414 | |
| 415 | add_executable(test_opus_encode ${test_opus_encode_sources}) |
| 416 | target_include_directories(test_opus_encode |
| 417 | PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt) |
| 418 | target_link_libraries(test_opus_encode PRIVATE opus) |
| 419 | add_test(test_opus_encode test_opus_encode) |
| 420 | endif() |
| 421 | endif() |