x265-1.9-enable_static-1.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Submitted By: Fernando de Oliveira <famobr at yahoo dot com dot br>
  2. Date: 2015-10-24
  3. Initial Package Version: 1.8
  4. Upstream Status: not submitted
  5. Origin: https://bitbucket.org/TimothyGu/x265/commits/a9aacc5a16116f1c663d1fcb62ad9a0985043b94/raw/
  6. https://bitbucket.org/TimothyGu/x265/commits/578c5ef3dff46db38e7c36a8d3c6198a65c9746b/raw/
  7. Description: Add ENABLE_STATIC:BOOL=ON, so that static lib
  8. can be disabled.
  9. --- x265_11047/source/CMakeLists.txt.orig 2015-10-08 07:01:36.000000000 -0300
  10. +++ x265_11047/source/CMakeLists.txt 2015-10-24 17:10:57.919861668 -0300
  11. @@ -419,16 +419,21 @@
  12. endif()
  13. source_group(ASM FILES ${YASM_SRCS})
  14. -add_library(x265-static STATIC $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
  15. -if(NOT MSVC)
  16. - set_target_properties(x265-static PROPERTIES OUTPUT_NAME x265)
  17. -endif()
  18. -if(EXTRA_LIB)
  19. - target_link_libraries(x265-static ${EXTRA_LIB})
  20. -endif()
  21. -install(TARGETS x265-static
  22. - LIBRARY DESTINATION ${LIB_INSTALL_DIR}
  23. - ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
  24. +
  25. +option(ENABLE_STATIC "Build static library" ON)
  26. +if(ENABLE_STATIC)
  27. + add_library(x265-static STATIC $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
  28. + if(NOT MSVC)
  29. + set_target_properties(x265-static PROPERTIES OUTPUT_NAME x265)
  30. + endif()
  31. + if(EXTRA_LIB)
  32. + target_link_libraries(x265-static ${EXTRA_LIB})
  33. + endif()
  34. + install(TARGETS x265-static
  35. + LIBRARY DESTINATION ${LIB_INSTALL_DIR}
  36. + ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
  37. +endif(ENABLE_STATIC)
  38. +
  39. install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include)
  40. if(CMAKE_RC_COMPILER)
  41. @@ -490,6 +495,10 @@
  42. endif()
  43. endif()
  44. +if(NOT ENABLE_STATIC AND NOT ENABLE_SHARED)
  45. + message(FATAL_ERROR "Neither static nor shared libraries are enabled.")
  46. +endif()
  47. +
  48. if(X265_LATEST_TAG)
  49. # convert lists of link libraries into -lstdc++ -lm etc..
  50. foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS})
  51. @@ -551,12 +560,14 @@
  52. else()
  53. add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${GETOPT} ${X265_RC_FILE}
  54. ${ExportDefs} x265.cpp x265.h x265cli.h x265-extras.h x265-extras.cpp)
  55. - if(WIN32 OR NOT ENABLE_SHARED OR INTEL_CXX)
  56. - # The CLI cannot link to the shared library on Windows, it
  57. - # requires internal APIs not exported from the DLL
  58. - target_link_libraries(cli x265-static ${PLATFORM_LIBS})
  59. - else()
  60. + if(WIN32 AND NOT ENABLE_STATIC)
  61. + message(FATAL_ERROR "The CLI cannot link to shared library on Windows as it requires internal APIs not exported from the DLL.")
  62. + elseif(INTEL_CXX AND NOT ENABLE_STATIC)
  63. + message(FATAL_ERROR "The CLI cannot link to shared library with Intel C++ Compiler as it requires internal APIs not exported from the shared library.")
  64. + elseif(ENABLE_SHARED)
  65. target_link_libraries(cli x265-shared ${PLATFORM_LIBS})
  66. + else()
  67. + target_link_libraries(cli x265-static ${PLATFORM_LIBS})
  68. endif()
  69. endif()
  70. set_target_properties(cli PROPERTIES OUTPUT_NAME x265)