cmake.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index c8d6d900..b8134168 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -75,7 +75,6 @@ if(MSVC)
  6. endif()
  7. # Need to set PIC to allow creating shared libraries from object file libraries.
  8. -set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  9. # Build the set of objects that do not need to be compiled with flags to enable
  10. # particular architecture features.
  11. @@ -174,19 +173,14 @@ if(LOONGARCH64)
  12. endif()
  13. # this creates the static library (.a)
  14. -add_library( ${ly_lib_static} STATIC ${ly_lib_parts})
  15. -
  16. -# this creates the shared library (.so)
  17. -add_library( ${ly_lib_shared} SHARED ${ly_lib_parts})
  18. -set_target_properties( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
  19. -set_target_properties( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
  20. -if(WIN32)
  21. - set_target_properties( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
  22. +ADD_LIBRARY( ${ly_lib_static} ${ly_lib_parts})
  23. +if (BUILD_SHARED_LIBS)
  24. + add_definitions("-DLIBYUV_BUILDING_SHARED_LIBRARY")
  25. endif()
  26. +option(BUILD_TOOLS "Build tools" OFF)
  27. +if (BUILD_TOOLS)
  28. # this creates the cpuid tool
  29. -add_executable ( cpuid ${ly_base_dir}/util/cpuid.c )
  30. -target_link_libraries ( cpuid ${ly_lib_static} )
  31. # this creates the conversion tool
  32. add_executable ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
  33. @@ -195,12 +189,21 @@ target_link_libraries ( yuvconvert ${ly_lib_static} )
  34. # this creates the yuvconstants tool
  35. add_executable ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
  36. target_link_libraries ( yuvconstants ${ly_lib_static} )
  37. -
  38. -find_package ( JPEG )
  39. -if (JPEG_FOUND)
  40. - include_directories( ${JPEG_INCLUDE_DIR} )
  41. - target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
  42. - add_definitions( -DHAVE_JPEG )
  43. +include(CheckFunctionExists)
  44. +check_function_exists(round HAVE_MATH_SYSTEM)
  45. +if(NOT HAVE_MATH_SYSTEM)
  46. + target_link_libraries(yuvconstants m)
  47. +endif()
  48. +INSTALL(TARGETS yuvconvert yuvconstants DESTINATION bin)
  49. +endif()
  50. +option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" OFF)
  51. +if (LIBYUV_WITH_JPEG)
  52. + find_package(JPEG REQUIRED)
  53. + target_link_libraries(${ly_lib_static} JPEG::JPEG )
  54. + target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG)
  55. + if (BUILD_TOOLS)
  56. + target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG)
  57. + endif()
  58. endif()
  59. if(UNIT_TEST)
  60. @@ -246,9 +249,7 @@ endif()
  61. # install the conversion tool, .so, .a, and all the header files
  62. -install ( TARGETS yuvconvert DESTINATION bin )
  63. -install ( TARGETS ${ly_lib_static} DESTINATION lib )
  64. -install ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
  65. +install ( TARGETS ${ly_lib_static} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
  66. install ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
  67. # create the .deb and .rpm packages using cpack