CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. cmake_minimum_required(VERSION 3.0)
  2. project(theora LANGUAGES C)
  3. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
  4. FIND_PACKAGE(Ogg REQUIRED)
  5. file(GLOB HEADERS
  6. "include/theora/codec.h"
  7. "include/theora/theora.h"
  8. "include/theora/theoradec.h"
  9. "include/theora/theoraenc.h"
  10. )
  11. set(LIBTHEORA_COMMON
  12. "lib/apiwrapper.c"
  13. "lib/bitpack.c"
  14. "lib/dequant.c"
  15. "lib/fragment.c"
  16. "lib/idct.c"
  17. "lib/info.c"
  18. "lib/internal.c"
  19. "lib/state.c"
  20. "lib/quant.c"
  21. "lib/x86_vc/mmxfrag.c"
  22. "lib/x86_vc/mmxidct.c"
  23. "lib/x86_vc/mmxstate.c"
  24. "lib/x86_vc/x86cpu.c"
  25. "lib/x86_vc/x86state.c"
  26. )
  27. set(LIBTHEORA_ENC
  28. "lib/analyze.c"
  29. "lib/encapiwrapper.c"
  30. "lib/encfrag.c"
  31. "lib/encinfo.c"
  32. "lib/encode.c"
  33. "lib/enquant.c"
  34. "lib/fdct.c"
  35. "lib/huffenc.c"
  36. "lib/mathops.c"
  37. "lib/mcenc.c"
  38. "lib/rate.c"
  39. "lib/tokenize.c"
  40. "lib/x86_vc/mmxencfrag.c"
  41. "lib/x86_vc/mmxfdct.c"
  42. "lib/x86_vc/x86enc.c"
  43. )
  44. set(LIBTHEORA_DEC
  45. "lib/decapiwrapper.c"
  46. "lib/decinfo.c"
  47. "lib/decode.c"
  48. "lib/huffdec.c"
  49. )
  50. add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  51. add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
  52. option(USE_X86 "Use x86 optimization" OFF)
  53. if(USE_X86)
  54. add_definitions(-DOC_X86_ASM)
  55. endif()
  56. if (BUILD_SHARED_LIBS)
  57. add_definitions(-DLIBTHEORA_EXPORTS)
  58. endif()
  59. add_library(theora-common OBJECT ${LIBTHEORA_COMMON} ${HEADERS})
  60. target_link_libraries(theora-common PUBLIC Ogg::ogg)
  61. target_include_directories(theora-common PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  62. add_library(theora-enc OBJECT ${LIBTHEORA_ENC} ${HEADERS})
  63. target_link_libraries(theora-enc PUBLIC Ogg::ogg)
  64. target_include_directories(theora-enc PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  65. add_library(theora-dec OBJECT ${LIBTHEORA_DEC} ${HEADERS})
  66. target_link_libraries(theora-dec PUBLIC Ogg::ogg)
  67. target_include_directories(theora-dec PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  68. add_library(theora $<TARGET_OBJECTS:theora-common> $<TARGET_OBJECTS:theora-enc> $<TARGET_OBJECTS:theora-dec> "libtheora.def")
  69. target_link_libraries(theora PUBLIC Ogg::ogg)
  70. target_include_directories(theora PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  71. add_library(theoraenc $<TARGET_OBJECTS:theora-common> $<TARGET_OBJECTS:theora-enc> "win32/xmingw32/libtheoraenc-all.def")
  72. target_link_libraries(theoraenc PUBLIC Ogg::ogg)
  73. target_include_directories(theoraenc PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  74. add_library(theoradec $<TARGET_OBJECTS:theora-common> $<TARGET_OBJECTS:theora-dec> "win32/xmingw32/libtheoradec-all.def")
  75. target_link_libraries(theoradec PUBLIC Ogg::ogg)
  76. target_include_directories(theoradec PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  77. include(CMakePackageConfigHelpers)
  78. configure_package_config_file(unofficial-theora-config.cmake.in unofficial-theora-config.cmake
  79. INSTALL_DESTINATION "lib/unofficial-theora")
  80. install(FILES ${HEADERS} DESTINATION include/theora)
  81. install(
  82. FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-theora-config.cmake"
  83. DESTINATION "lib/unofficial-theora"
  84. )
  85. install(TARGETS theora theoraenc theoradec
  86. EXPORT unofficial-theora-targets
  87. RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  88. LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  89. ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  90. )
  91. install(EXPORT unofficial-theora-targets
  92. NAMESPACE unofficial::theora::
  93. DESTINATION "lib/unofficial-theora"
  94. )