opus_config.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. include(opus_functions.cmake)
  2. configure_file(config.h.cmake.in config.h @ONLY)
  3. add_definitions(-DHAVE_CONFIG_H)
  4. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  5. set_property(GLOBAL PROPERTY C_STANDARD 99)
  6. if(MSVC)
  7. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  8. endif()
  9. include(CheckLibraryExists)
  10. check_library_exists(m floor "" HAVE_LIBM)
  11. if(HAVE_LIBM)
  12. list(APPEND OPUS_REQUIRED_LIBRARIES m)
  13. endif()
  14. include(CFeatureCheck)
  15. c_feature_check(VLA)
  16. include(CheckIncludeFile)
  17. check_include_file(alloca.h HAVE_ALLOCA_H)
  18. include(CheckSymbolExists)
  19. if(HAVE_ALLOCA_H)
  20. add_definitions(-DHAVE_ALLOCA_H)
  21. check_symbol_exists(alloca "alloca.h" USE_ALLOCA_SUPPORTED)
  22. else()
  23. check_symbol_exists(alloca "stdlib.h;malloc.h" USE_ALLOCA_SUPPORTED)
  24. endif()
  25. include(CheckFunctionExists)
  26. check_function_exists(lrintf HAVE_LRINTF)
  27. check_function_exists(lrint HAVE_LRINT)
  28. if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
  29. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  30. set(OPUS_CPU_X64 1)
  31. else()
  32. set(OPUS_CPU_X86 1)
  33. endif()
  34. elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
  35. set(OPUS_CPU_ARM 1)
  36. endif()
  37. opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION)
  38. if(OPUS_CPU_X86 OR OPUS_CPU_X64)
  39. opus_detect_sse(COMPILER_SUPPORT_SIMD)
  40. elseif(OPUS_CPU_ARM)
  41. opus_detect_neon(COMPILER_SUPPORT_NEON)
  42. if(COMPILER_SUPPORT_NEON)
  43. option(OPUS_USE_NEON "Option to enable NEON" ON)
  44. option(OPUS_MAY_HAVE_NEON "Does runtime check for neon support" ON)
  45. option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF)
  46. if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
  47. set(OPUS_PRESUME_NEON ON)
  48. elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
  49. set(OPUS_PRESUME_NEON ON)
  50. endif()
  51. endif()
  52. endif()