1 2if(ENABLE_GITEE) 3 set(REQ_URL "https://gitee.com/mirrors/libjpeg-turbo/repository/archive/2.0.4.tar.gz") 4 set(MD5 "8b76d3d3bea23ddfb0c1e65f94f11b83") 5else() 6 set(REQ_URL "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.4.tar.gz") 7 set(MD5 "44c43e4a9fb352f47090804529317c88") 8endif() 9 10if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 11 set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \ 12 -O2") 13else() 14 set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \ 15 -D_FORTIFY_SOURCE=2 -O2") 16endif() 17 18set(jpeg_turbo_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack,-s") 19 20 21set(jpeg_turbo_USE_STATIC_LIBS ON) 22set(JPEG_TURBO_PATCHE ${CMAKE_SOURCE_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001) 23set(CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=TRUE -DWITH_SIMD=ON) 24if(BUILD_LITE) 25 set(jpeg_turbo_USE_STATIC_LIBS OFF) 26 set(JPEG_TURBO_PATCHE ${TOP_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001) 27 if(PLATFORM_ARM64) 28 set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake 29 -DANDROID_NATIVE_API_LEVEL=19 30 -DANDROID_NDK=$ENV{ANDROID_NDK} 31 -DANDROID_ABI=arm64-v8a 32 -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang 33 -DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) 34 endif() 35 if(PLATFORM_ARM32) 36 set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake 37 -DANDROID_NATIVE_API_LEVEL=19 38 -DANDROID_NDK=$ENV{ANDROID_NDK} 39 -DANDROID_ABI=armeabi-v7a 40 -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang 41 -DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) 42 endif() 43 44endif() 45 46mindspore_add_pkg(jpeg_turbo 47 VER 2.0.4 48 LIBS jpeg turbojpeg 49 URL ${REQ_URL} 50 MD5 ${MD5} 51 CMAKE_OPTION ${CMAKE_OPTION} 52 PATCHES ${JPEG_TURBO_PATCHE} 53 ) 54include_directories(${jpeg_turbo_INC}) 55add_library(mindspore::jpeg_turbo ALIAS jpeg_turbo::jpeg) 56add_library(mindspore::turbojpeg ALIAS jpeg_turbo::turbojpeg) 57