2017-06-20 20:19:43 +08:00
|
|
|
set(the_description "Image I/O")
|
2020-06-09 02:32:53 +08:00
|
|
|
ocv_add_module(imgcodecs opencv_imgproc WRAP java objc python)
|
2014-07-04 22:48:15 +08:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# CMake file for imgcodecs. See root CMakeLists.txt
|
|
|
|
# Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
|
|
|
|
# Jose Luis Blanco, 2008
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ocv_clear_vars(GRFMT_LIBS)
|
|
|
|
|
2015-02-21 00:47:45 +08:00
|
|
|
if(HAVE_WINRT_CX AND NOT WINRT)
|
2014-07-04 22:48:15 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
|
|
|
endif()
|
|
|
|
|
2023-06-09 20:39:10 +08:00
|
|
|
if (HAVE_AVIF)
|
|
|
|
ocv_include_directories(${AVIF_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${AVIF_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2014-07-04 22:48:15 +08:00
|
|
|
if(HAVE_JPEG)
|
2018-05-10 22:02:24 +08:00
|
|
|
ocv_include_directories(${JPEG_INCLUDE_DIR} ${${JPEG_LIBRARY}_BINARY_DIR})
|
2014-07-04 22:48:15 +08:00
|
|
|
list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2017-06-13 00:10:13 +08:00
|
|
|
if(HAVE_WEBP)
|
2014-07-04 22:48:15 +08:00
|
|
|
add_definitions(-DHAVE_WEBP)
|
|
|
|
ocv_include_directories(${WEBP_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2022-06-11 04:23:42 +08:00
|
|
|
if(HAVE_SPNG)
|
|
|
|
add_definitions(${SPNG_DEFINITIONS})
|
|
|
|
ocv_include_directories(${SPNG_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${SPNG_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2014-07-04 22:48:15 +08:00
|
|
|
if(HAVE_PNG)
|
|
|
|
add_definitions(${PNG_DEFINITIONS})
|
|
|
|
ocv_include_directories(${PNG_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2015-04-20 20:27:57 +08:00
|
|
|
if(HAVE_GDCM)
|
|
|
|
ocv_include_directories(${GDCM_INCLUDE_DIRS})
|
|
|
|
list(APPEND GRFMT_LIBS ${GDCM_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2014-07-04 22:48:15 +08:00
|
|
|
if(HAVE_TIFF)
|
|
|
|
ocv_include_directories(${TIFF_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2020-03-27 15:18:58 +08:00
|
|
|
if(HAVE_OPENJPEG)
|
|
|
|
ocv_include_directories(${OPENJPEG_INCLUDE_DIRS})
|
|
|
|
list(APPEND GRFMT_LIBS ${OPENJPEG_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2014-07-04 22:48:15 +08:00
|
|
|
if(HAVE_JASPER)
|
|
|
|
ocv_include_directories(${JASPER_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
|
2019-03-15 04:52:30 +08:00
|
|
|
if(OPENCV_IO_FORCE_JASPER)
|
|
|
|
add_definitions(-DOPENCV_IMGCODECS_FORCE_JASPER=1)
|
2021-12-23 17:58:56 +08:00
|
|
|
else()
|
|
|
|
message(STATUS "imgcodecs: Jasper codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/14058")
|
2019-03-15 04:52:30 +08:00
|
|
|
endif()
|
2014-07-04 22:48:15 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_OPENEXR)
|
|
|
|
include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
|
|
|
|
list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
|
2021-12-23 17:58:56 +08:00
|
|
|
if(OPENCV_IO_FORCE_OPENEXR
|
|
|
|
OR NOT BUILD_OPENEXR # external OpenEXR versions are not disabled
|
|
|
|
)
|
|
|
|
add_definitions(-DOPENCV_IMGCODECS_USE_OPENEXR=1)
|
|
|
|
else()
|
|
|
|
message(STATUS "imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326")
|
|
|
|
endif()
|
2014-07-04 22:48:15 +08:00
|
|
|
endif()
|
|
|
|
|
2022-06-11 04:23:42 +08:00
|
|
|
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR OR HAVE_SPNG)
|
2021-02-12 22:19:35 +08:00
|
|
|
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2014-08-13 22:24:11 +08:00
|
|
|
if(HAVE_GDAL)
|
|
|
|
include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
|
|
|
|
list(APPEND GRFMT_LIBS ${GDAL_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2018-05-22 23:10:15 +08:00
|
|
|
if(HAVE_IMGCODEC_HDR)
|
|
|
|
add_definitions(-DHAVE_IMGCODEC_HDR)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_IMGCODEC_SUNRASTER)
|
|
|
|
add_definitions(-DHAVE_IMGCODEC_SUNRASTER)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_IMGCODEC_PXM)
|
|
|
|
add_definitions(-DHAVE_IMGCODEC_PXM)
|
|
|
|
endif()
|
|
|
|
|
2018-08-13 18:14:12 +08:00
|
|
|
if (HAVE_IMGCODEC_PFM)
|
|
|
|
add_definitions(-DHAVE_IMGCODEC_PFM)
|
|
|
|
endif()
|
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
file(GLOB grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.hpp)
|
|
|
|
file(GLOB grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.cpp)
|
2015-04-20 20:27:57 +08:00
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.hpp)
|
|
|
|
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.cpp)
|
|
|
|
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.hpp)
|
|
|
|
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.cpp)
|
2016-11-10 01:09:22 +08:00
|
|
|
list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/exif.hpp)
|
|
|
|
list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/exif.cpp)
|
2014-07-04 22:48:15 +08:00
|
|
|
|
|
|
|
source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
|
|
|
|
|
|
|
|
set(imgcodecs_hdrs
|
2014-08-01 22:11:20 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/utils.hpp
|
2014-07-04 22:48:15 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set(imgcodecs_srcs
|
2014-08-01 22:11:20 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/loadsave.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/utils.cpp
|
2014-07-04 22:48:15 +08:00
|
|
|
)
|
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
file(GLOB imgcodecs_ext_hdrs
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
|
2018-11-24 01:02:46 +08:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/legacy/*.h"
|
2014-08-01 22:11:20 +08:00
|
|
|
)
|
2014-07-04 22:48:15 +08:00
|
|
|
|
2020-11-20 05:20:32 +08:00
|
|
|
if(APPLE OR APPLE_FRAMEWORK)
|
2020-10-15 00:58:06 +08:00
|
|
|
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/apple_conversions.h)
|
|
|
|
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/apple_conversions.mm)
|
|
|
|
endif()
|
2023-12-20 20:35:10 +08:00
|
|
|
if(IOS OR XROS)
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm)
|
Merge pull request #18826 from Rightpoint:feature/colejd/build-catalyst-xcframework
Support XCFramework builds, Catalyst
* Early work on xcframework support
* Improve legibility
* Somehow this works
* Specify ABIs in a place where they won't get erased
If you pass in the C/CXX flags from the Python script, they won't be respected. By doing it in the actual toolchain, the options are respected and Catalyst successfully links.
* Clean up and push updates
* Actually use Catalyst ABI
Needed to specify EXE linker flags to get compiler tests to link to the Catalyst ABIs.
* Clean up
* Revert changes to common toolchain that don't matter
* Try some things
* Support Catalyst build in OSX scripts
* Remove unnecessary iOS reference to AssetsLibrary framework
* Getting closer
* Try some things, port to Python 3
* Some additional fixes
* Point Cmake Plist gen to osx directory for Catalyst targets
* Remove dynamic lib references for Catalyst, copy iOS instead of macos
* Add flag for building only specified archs, remove iOS catalyst refs
* Add build-xcframework.sh
* Update build-xcframework.sh
* Add presumptive Apple Silicon support
* Add arm64 iphonesimulator target
* Fix xcframework build
* Working on arm64 iOS simulator
* Support 2.7 (replace run with check_output)
* Correctly check output of uname_m against arch
* Clean up
* Use lipo for intermediate frameworks, add python script
Remove unneeded __init__.py
* Simplify python xcframework build script
* Add --only-64-bit flag
* Add --framework-name flag
* Document
* Commit to f-strings, improve console output
* Add i386 to iphonesimulator platform in xcframework generator
* Enable objc for non-Catalyst frameworks
* Fix xcframework builder for paths with spaces
* Use arch when specifying Catalyst build platform in build command
* Fix incorrect settings for framework_name argparse configuration
* Prefer underscores instead of hyphens in new flags
* Move Catalyst flags to where they'll actually get used
* Use --without=objc on Catalyst target for now
* Remove get_or_create_folder and simplify logic
* Remove unused import
* Tighten up help text
* Document
* Move common functions into cv_build_utils
* Improve documentation
* Remove old build script
* Add readme
* Check for required CMake and Xcode versions
* Clean up TODOs and re-enable `copy_samples()`
Remove TODO
Fixup
* Add missing print_function import
* Clarify CMake dependency documentation
* Revert python2 change in gen_objc
* Remove unnecessary builtins imports
* Remove trailing whitespace
* Avoid building Catalyst unless specified
This makes Catalyst support a non-breaking change, though defaults should be specified when a breaking change is possible.
* Prevent lipoing for the same archs on different platforms before build
* Rename build-xcframework.py to build_xcframework.py
* Check for duplicate archs more carefully
* Prevent sample copying error when directory already exists
This can happen when building multiple architectures for the same platform.
* Simplify code for checking for default archs
* Improve build_xcframework.py header text
* Correctly resolve Python script paths
* Parse only known args in ios/osx build_framework.py
* Pass through uncaptured args in build_xcframework to osx/ios build
* Fix typo
* Fix typo
* Fix unparameterized build path for intermediate frameworks
* Fix dyanmic info.plist path for catalyst
* Fix utf-8 Python 3 issue
* Add dynamic flag to osx script
* Rename platform to platforms, remove armv7s and i386
* Fix creation of dynamic framework on maccatalyst and macos
* Update platforms/apple/readme.md
* Add `macos_archs` flag and deprecate `archs` flag
* Allow specification of archs when generating xcframework from terminal
* Change xcframework platform argument names to match archs flag names
* Remove platforms as a concept and shadow archs flags from ios/osx .py
* Improve documentation
* Fix building of objc module on Catalyst, excluding Swift
* Clean up build folder logic a bit
* Fix framework_name flag
* Drop passthrough_args, use unknown_args instead
* minor: coding style changes
Co-authored-by: Chris Ballinger <cballinger@rightpoint.com>
2020-11-25 05:54:54 +08:00
|
|
|
list(APPEND IMGCODECS_LIBRARIES "-framework UIKit")
|
2014-07-04 22:48:15 +08:00
|
|
|
endif()
|
2023-12-20 20:35:10 +08:00
|
|
|
if(APPLE AND (NOT IOS) AND (NOT XROS))
|
2020-10-15 00:58:06 +08:00
|
|
|
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/macosx_conversions.mm)
|
|
|
|
list(APPEND IMGCODECS_LIBRARIES "-framework AppKit")
|
|
|
|
endif()
|
2017-02-21 17:52:06 +08:00
|
|
|
if(APPLE_FRAMEWORK)
|
2020-06-09 02:32:53 +08:00
|
|
|
list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework QuartzCore")
|
2017-02-21 17:52:06 +08:00
|
|
|
endif()
|
2014-07-04 22:48:15 +08:00
|
|
|
|
2019-04-16 05:29:17 +08:00
|
|
|
if(TRUE)
|
|
|
|
# these variables are set by 'ocv_append_build_options(IMGCODECS ...)'
|
2014-07-04 22:48:15 +08:00
|
|
|
foreach(P ${IMGCODECS_INCLUDE_DIRS})
|
|
|
|
ocv_include_directories(${P})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(P ${IMGCODECS_LIBRARY_DIRS})
|
|
|
|
link_directories(${P})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
source_group("Src" FILES ${imgcodecs_srcs} ${imgcodecs_hdrs})
|
|
|
|
source_group("Include" FILES ${imgcodecs_ext_hdrs})
|
|
|
|
ocv_set_module_sources(HEADERS ${imgcodecs_ext_hdrs} SOURCES ${imgcodecs_srcs} ${imgcodecs_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
|
|
|
|
ocv_module_include_directories()
|
|
|
|
|
|
|
|
ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES})
|
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
macro(ocv_imgcodecs_configure_target)
|
2014-07-04 22:48:15 +08:00
|
|
|
if(APPLE)
|
2021-02-13 08:35:18 +08:00
|
|
|
add_apple_compiler_options(${the_module})
|
2014-07-04 22:48:15 +08:00
|
|
|
endif()
|
|
|
|
|
2021-10-04 20:42:51 +08:00
|
|
|
if(MSVC AND NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
|
2014-07-04 22:48:15 +08:00
|
|
|
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
|
2014-08-01 22:11:20 +08:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
if(NOT BUILD_opencv_world)
|
|
|
|
ocv_imgcodecs_configure_target()
|
|
|
|
endif()
|
2014-07-04 22:48:15 +08:00
|
|
|
|
|
|
|
ocv_add_accuracy_tests()
|
2019-03-15 04:52:30 +08:00
|
|
|
if(TARGET opencv_test_imgcodecs AND HAVE_JASPER AND "$ENV{OPENCV_IO_ENABLE_JASPER}")
|
|
|
|
ocv_target_compile_definitions(opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_ENABLE_JASPER_TESTS=1)
|
|
|
|
endif()
|
2021-12-23 17:58:56 +08:00
|
|
|
if(TARGET opencv_test_imgcodecs AND HAVE_OPENEXR AND "$ENV{OPENCV_IO_ENABLE_OPENEXR}")
|
|
|
|
ocv_target_compile_definitions(opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_ENABLE_OPENEXR_TESTS=1)
|
|
|
|
endif()
|
2022-08-31 16:57:48 +08:00
|
|
|
if(TARGET opencv_test_imgcodecs AND ((HAVE_PNG AND NOT (PNG_VERSION VERSION_LESS "1.6.31")) OR HAVE_SPNG))
|
2021-02-16 20:32:58 +08:00
|
|
|
# details: https://github.com/glennrp/libpng/commit/68cb0aaee3de6371b81a4613476d9b33e43e95b1
|
|
|
|
ocv_target_compile_definitions(opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_PNG_WITH_EXIF=1)
|
|
|
|
endif()
|
2014-07-04 22:48:15 +08:00
|
|
|
ocv_add_perf_tests()
|