|
|
@ -15,8 +15,55 @@ endif() |
|
|
|
|
|
|
|
|
|
|
|
message(STATUS "libjpeg-turbo: VERSION = ${VERSION}, BUILD = ${BUILD}") |
|
|
|
message(STATUS "libjpeg-turbo: VERSION = ${VERSION}, BUILD = ${BUILD}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8") |
|
|
|
|
|
|
|
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR |
|
|
|
|
|
|
|
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR |
|
|
|
|
|
|
|
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR |
|
|
|
|
|
|
|
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR |
|
|
|
|
|
|
|
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32") |
|
|
|
|
|
|
|
if(BITS EQUAL 64 OR CMAKE_C_COMPILER_ABI MATCHES "ELF X32") |
|
|
|
|
|
|
|
set(CPU_TYPE x86_64) |
|
|
|
|
|
|
|
else() |
|
|
|
|
|
|
|
set(CPU_TYPE i386) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE}) |
|
|
|
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE}) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR |
|
|
|
|
|
|
|
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm") |
|
|
|
|
|
|
|
if(BITS EQUAL 64) |
|
|
|
|
|
|
|
set(CPU_TYPE arm64) |
|
|
|
|
|
|
|
else() |
|
|
|
|
|
|
|
set(CPU_TYPE arm) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^ppc" OR |
|
|
|
|
|
|
|
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^powerpc") |
|
|
|
|
|
|
|
set(CPU_TYPE powerpc) |
|
|
|
|
|
|
|
else() |
|
|
|
|
|
|
|
set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC}) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR |
|
|
|
|
|
|
|
CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR |
|
|
|
|
|
|
|
CMAKE_OSX_ARCHITECTURES MATCHES "i386") |
|
|
|
|
|
|
|
set(CPU_TYPE ${CMAKE_OSX_ARCHITECTURES}) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
if(CMAKE_OSX_ARCHITECTURES MATCHES "ppc") |
|
|
|
|
|
|
|
set(CPU_TYPE powerpc) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64") |
|
|
|
|
|
|
|
set(CPU_TYPE arm64) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message(STATUS "${BITS}-bit build (${CPU_TYPE})") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OCV_OPTION(ENABLE_LIBJPEG_TURBO_SIMD "Include SIMD extensions for libjpeg-turbo, if available for this platform" (NOT CV_DISABLE_OPTIMIZATION) |
|
|
|
|
|
|
|
VISIBLE_IF BUILD_JPEG) |
|
|
|
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE) |
|
|
|
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE) |
|
|
|
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE) |
|
|
|
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE) |
|
|
|
|
|
|
|
set(WITH_SIMD 1) |
|
|
|
|
|
|
|
set(IS_LIBJPEG_TURBO_SIMD_AVAILABLE 0 PARENT_SCOPE) |
|
|
|
|
|
|
|
|
|
|
|
include(CheckCSourceCompiles) |
|
|
|
include(CheckCSourceCompiles) |
|
|
|
include(CheckIncludeFiles) |
|
|
|
include(CheckIncludeFiles) |
|
|
@ -99,12 +146,73 @@ if(WITH_ARITH_DEC) |
|
|
|
set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c) |
|
|
|
set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c) |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
# No SIMD |
|
|
|
if(MSVC) |
|
|
|
set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c) |
|
|
|
option(WITH_CRT_DLL |
|
|
|
|
|
|
|
"Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.) The default is to use the C run-time DLL only with the libraries and executables that need it." |
|
|
|
|
|
|
|
FALSE) |
|
|
|
|
|
|
|
if(NOT WITH_CRT_DLL) |
|
|
|
|
|
|
|
# Use the static C library for all build types |
|
|
|
|
|
|
|
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE |
|
|
|
|
|
|
|
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) |
|
|
|
|
|
|
|
if(${var} MATCHES "/MD") |
|
|
|
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}") |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
endforeach() |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") |
|
|
|
|
|
|
|
# Use the maximum optimization level for release builds |
|
|
|
|
|
|
|
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) |
|
|
|
|
|
|
|
if(${var} MATCHES "-O2") |
|
|
|
|
|
|
|
string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}") |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
endforeach() |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
|
|
|
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "SunPro") |
|
|
|
|
|
|
|
# Use the maximum optimization level for release builds |
|
|
|
|
|
|
|
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) |
|
|
|
|
|
|
|
if(${var} MATCHES "-xO3") |
|
|
|
|
|
|
|
string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}") |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
if(${var} MATCHES "-xO2") |
|
|
|
|
|
|
|
string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}") |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
endforeach() |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message(STATUS ${WITH_LIBJPEG_TURBO_SIMD}) |
|
|
|
|
|
|
|
if(ENABLE_LIBJPEG_TURBO_SIMD) |
|
|
|
|
|
|
|
add_subdirectory(src/simd) |
|
|
|
|
|
|
|
if(NEON_INTRINSICS) |
|
|
|
|
|
|
|
add_definitions(-DNEON_INTRINSICS) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
else() |
|
|
|
|
|
|
|
set(WITH_SIMD 0) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(WITH_SIMD) |
|
|
|
|
|
|
|
message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})") |
|
|
|
|
|
|
|
set(IS_LIBJPEG_TURBO_SIMD_AVAILABLE 1 PARENT_SCOPE) |
|
|
|
|
|
|
|
if(MSVC_IDE OR XCODE) |
|
|
|
|
|
|
|
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
else() |
|
|
|
|
|
|
|
add_library(simd OBJECT src/jsimd_none.c) |
|
|
|
|
|
|
|
if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED)) |
|
|
|
|
|
|
|
set_target_properties(simd PROPERTIES POSITION_INDEPENDENT_CODE 1) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
ocv_list_add_prefix(JPEG_SOURCES src/) |
|
|
|
ocv_list_add_prefix(JPEG_SOURCES src/) |
|
|
|
|
|
|
|
|
|
|
|
add_library(${JPEG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${JPEG_SOURCES} ${SIMD_OBJS}) |
|
|
|
set(JPEG_SOURCES ${JPEG_SOURCES} ${SIMD_OBJS}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_library(${JPEG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${JPEG_SOURCES} $<TARGET_OBJECTS:simd> ${SIMD_OBJS}) |
|
|
|
|
|
|
|
|
|
|
|
set_target_properties(${JPEG_LIBRARY} |
|
|
|
set_target_properties(${JPEG_LIBRARY} |
|
|
|
PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY} |
|
|
|
PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY} |
|
|
|