cmake.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 3f521e3..4d742f3 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -73,7 +73,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. @@ -120,19 +119,15 @@ if(NOT MSVC)
  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. +# this creates the shared library (.so)
  27. +option(BUILD_TOOLS "Build tools" OFF)
  28. +if (BUILD_TOOLS)
  29. # this creates the cpuid tool
  30. -ADD_EXECUTABLE ( cpuid ${ly_base_dir}/util/cpuid.c )
  31. -TARGET_LINK_LIBRARIES ( cpuid ${ly_lib_static} )
  32. # this creates the conversion tool
  33. ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
  34. @@ -141,12 +136,22 @@ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
  35. # this creates the yuvconstants tool
  36. ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
  37. TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} )
  38. +include(CheckFunctionExists)
  39. +check_function_exists(round HAVE_MATH_SYSTEM)
  40. +if(NOT HAVE_MATH_SYSTEM)
  41. + target_link_libraries(yuvconstants m)
  42. +endif()
  43. +INSTALL(TARGETS yuvconvert yuvconstants DESTINATION bin)
  44. +endif()
  45. -find_package ( JPEG )
  46. -if (JPEG_FOUND)
  47. - include_directories( ${JPEG_INCLUDE_DIR} )
  48. - target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
  49. - add_definitions( -DHAVE_JPEG )
  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. @@ -192,11 +197,8 @@ endif()
  61. # install the conversion tool, .so, .a, and all the header files
  62. -INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
  63. -INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
  64. -INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
  65. +INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
  66. INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
  67. # create the .deb and .rpm packages using cpack
  68. -INCLUDE ( CM_linux_packages.cmake )