CMakeLists.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # ----------------------------------------------------------------------------
  2. # CMake file for libpng. See root CMakeLists.txt
  3. #
  4. # ----------------------------------------------------------------------------
  5. if(ENABLE_NEON)
  6. project(${PNG_LIBRARY} C ASM)
  7. else()
  8. project(${PNG_LIBRARY} C)
  9. endif()
  10. if(NOT WIN32)
  11. find_library(M_LIBRARY
  12. NAMES m
  13. PATHS /usr/lib /usr/local/lib
  14. )
  15. if(NOT M_LIBRARY)
  16. message(STATUS "math lib 'libm' not found; floating point support disabled")
  17. endif()
  18. else()
  19. # not needed on windows
  20. set(M_LIBRARY "")
  21. endif()
  22. ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIRS})
  23. file(GLOB lib_srcs *.c)
  24. file(GLOB lib_hdrs *.h)
  25. if(ARM OR AARCH64)
  26. if(ENABLE_NEON)
  27. if(NOT AARCH64)
  28. list(APPEND lib_srcs arm/filter_neon.S)
  29. endif()
  30. list(APPEND lib_srcs arm/arm_init.c arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c)
  31. add_definitions(-DPNG_ARM_NEON_OPT=2)
  32. else()
  33. add_definitions(-DPNG_ARM_NEON_OPT=0) # NEON assembler is not supported
  34. endif()
  35. endif()
  36. if(";${CPU_BASELINE_FINAL};" MATCHES "SSE2"
  37. AND (NOT MSVC OR (MSVC_VERSION GREATER 1799))) # MSVS2013+ (issue #7232)
  38. list(APPEND lib_srcs intel/intel_init.c intel/filter_sse2_intrinsics.c)
  39. add_definitions(-DPNG_INTEL_SSE)
  40. endif()
  41. # set definitions and sources for MIPS
  42. if(";${CPU_BASELINE_FINAL};" MATCHES "MSA")
  43. list(APPEND lib_srcs mips/mips_init.c mips/filter_msa_intrinsics.c)
  44. add_definitions(-DPNG_MIPS_MSA_OPT=2)
  45. ocv_warnings_disable(CMAKE_C_FLAGS -Wshadow)
  46. else()
  47. add_definitions(-DPNG_MIPS_MSA_OPT=0)
  48. endif()
  49. if(PPC64LE OR PPC64)
  50. # VSX3 features are backwards compatible
  51. if(";${CPU_BASELINE_FINAL};" MATCHES "VSX.*"
  52. AND NOT PPC64)
  53. list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
  54. add_definitions(-DPNG_POWERPC_VSX_OPT=2)
  55. else()
  56. add_definitions(-DPNG_POWERPC_VSX_OPT=0)
  57. endif()
  58. endif()
  59. # ----------------------------------------------------------------------------------
  60. # Define the library target:
  61. # ----------------------------------------------------------------------------------
  62. if(MSVC)
  63. add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
  64. endif(MSVC)
  65. add_library(${PNG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
  66. target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
  67. ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wcast-align -Wimplicit-fallthrough -Wunused-parameter -Wsign-compare)
  68. set_target_properties(${PNG_LIBRARY}
  69. PROPERTIES OUTPUT_NAME ${PNG_LIBRARY}
  70. DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
  71. COMPILE_PDB_NAME ${PNG_LIBRARY}
  72. COMPILE_PDB_NAME_DEBUG "${PNG_LIBRARY}${OPENCV_DEBUG_POSTFIX}"
  73. ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
  74. )
  75. if(ENABLE_SOLUTION_FOLDERS)
  76. set_target_properties(${PNG_LIBRARY} PROPERTIES FOLDER "3rdparty")
  77. endif()
  78. if(NOT BUILD_SHARED_LIBS)
  79. ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
  80. endif()
  81. ocv_install_3rdparty_licenses(libpng LICENSE README)