首页 > 其他分享 >cjpeg 的 cmake配置

cjpeg 的 cmake配置

时间:2024-06-10 17:10:53浏览次数:24  
标签:SUPPORTED set CMAKE lib src cjpeg 配置 FLAGS cmake

# 设置构建类型

set(CMAKE_BUILD_TYPE Debug)
set(jpeg_lib "${CMAKE_CURRENT_SOURCE_DIR}/lib/jpeg.lib")
set(libpng_lib "C:/Users/20021/Desktop/vcpkg/packages/libpng_x64-windows/lib/libpng16.lib")
set(zlib_lib "C:/Users/20021/Desktop/vcpkg/packages/zlib_x64-windows/lib/zlib.lib")
set(src_dir ${CMAKE_CURRENT_SOURCE_DIR}/src)

# 添加预处理器定义
add_definitions(
  -DWIN32
  -D_WINDOWS
  -DBMP_SUPPORTED
  -DGIF_SUPPORTED
  -DPPM_SUPPORTED
  -DTARGA_SUPPORTED
  -DUSE_SETMODE
  -DPNG_SUPPORTED
  -D_CRT_NONSTDC_NO_WARNINGS
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)

if(MSVC)
  # Build all configurations against shared C library
  foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
    CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
    if(${var} MATCHES "/MT")
      string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")
    endif()
  endforeach()
endif()

if(WITH_SIMD AND(MSVC_IDE OR XCODE))
  # This tells CMake that the "source" files haven't been generated yet
  set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
endif()

if(WIN32)
  set(USE_SETMODE "-DUSE_SETMODE")
endif()

if(WITH_12BIT)
  set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}")
else()
  set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
  set(CJPEG_BMP_SOURCES ${src_dir}/rdbmp.c ${src_dir}/rdtarga.c)

  if(PNG_SUPPORTED)
    report_option(PNG_SUPPORTED "PNG reading support")
    set(COMPILE_FLAGS "${COMPILE_FLAGS} -DPNG_SUPPORTED")
    set(CJPEG_BMP_SOURCES ${CJPEG_BMP_SOURCES} ${src_dir}/rdpng.c)
  endif()
endif()

add_executable(cjpeg ${src_dir}/cjpeg.c ${src_dir}/cdjpeg.c ${src_dir}/rdgif.c ${src_dir}/rdppm.c ${src_dir}/rdjpeg.c
  ${src_dir}/rdswitch.c
  ${CMAKE_CURRENT_SOURCE_DIR}/include/cdjpeg.h
  ${CMAKE_CURRENT_SOURCE_DIR}/include/png.h
  ${CMAKE_CURRENT_SOURCE_DIR}/include/pngconf.h
  ${CMAKE_CURRENT_SOURCE_DIR}/include/pnglibconf.h
  ${CJPEG_BMP_SOURCES})
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})

# target_link_libraries(cjpeg jpeg)
target_link_libraries(cjpeg PUBLIC ${jpeg_lib} ${zlib_lib} ${libpng_lib})

target_include_directories(cjpeg PUBLIC
  "C:/Code/mozjpeg-4.1.5/build"
  "C:/Code/mozjpeg-4.1.5"
  "C:/Users/20021/Desktop/vcpkg/packages/libpng_x64-windows/include"
  "C:/Users/20021/Desktop/vcpkg/packages/zlib_x64-windows/include"
  "C:/Users/20021/Desktop/vcpkg/packages/libpng_x64-windows/include"
)

if(PNG_SUPPORTED)
  # to avoid finding static library from CMake cache
  unset(PNG_LIBRARY CACHE)
  unset(PNG_LIBRARY_RELEASE CACHE)
  unset(PNG_LIBRARY_DEBUG CACHE)
  unset(ZLIB_LIBRARY CACHE)
  unset(ZLIB_LIBRARY_RELEASE CACHE)
  unset(ZLIB_LIBRARY_DEBUG CACHE)
  set(CMAKE_PREFIX_PATH "C:/Users/20021/Desktop/vcpkg/packages/libpng_x64-windows;C:/Users/20021/Desktop/vcpkg/packages/zlib_x64-windows;C:/Users/20021/Desktop/vcpkg/packages/libpng_x64-windows/bin;C:/Users/20021/Desktop/vcpkg/packages/zlib_x64-windows/bin")
  find_package(PNG 1.6 REQUIRED)
  find_package(ZLIB REQUIRED)
  target_include_directories(cjpeg PUBLIC ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
  target_link_libraries(cjpeg ${PNG_LIBRARY} ${ZLIB_LIBRARY})
endif()

标签:SUPPORTED,set,CMAKE,lib,src,cjpeg,配置,FLAGS,cmake
From: https://www.cnblogs.com/DINGJINXING/p/18240823

相关文章

  • 架构设计-web项目中跨域问题涉及到的后端和前端配置
    WEB软件项目中经常会遇到跨域问题,解决方案早已是业内的共识,简要记录主流的处理方式:跨域感知session需要解决两个问题:1.跨域问题2.跨域cookie传输问题跨域问题解决跨域问题有很多种方式,如使用springboot自带的crossOrigin注解@CrossOrigin(origins={"*"},allowedHe......
  • EDGE浏览器新用户配置登录Microsoft账户出现0x80190001错误代码
    在网页内可以轻松反复登陆Microsoft账户,但是在EDGE浏览器上无法登陆。浏览器原本有一个用户配置,已经登陆了一个账号,在创建新的用户配置时,始终无法登陆账户。这个情况持续了两个星期  若是有使用代理,加速器,hosts修改器等,建议卸载一下。然后参考以下链接恢复hosts文件:https:/......
  • python-pip配置镜像源加速下载Python包安装:快速配置pip源-国内加速源
    目录一、简介二、国内常用加速源 三、配置pip加速源1.临时配置2.永久配置a.配置命令b.查看是否配置成功c.还原配置一、简介pip的原本安装源是PythonPackageIndex(PyPI)的官方源,其URL为https://pypi.org/simple/。PyPI是Python社区用来发布和共享软件包的官方仓......
  • 避免 OOMKilled:在 Kubernetes 环境中优化 Java 进程的内存配置
    避免OOMKilled:在Kubernetes环境中优化Java进程的内存配置DevOps云学堂译 奇妙的Linux世界 2024-06-1009:53 重庆 听全文公众号关注 「奇妙的Linux世界」设为「星标」,每天带你玩转Linux! 管理KubernetesPod中运行的Java进程的内存使用情况比人们想象......
  • 三、SpaceVim配置
    一、基本键位映射在配置vim的快捷键时,需要掌握基本键位的描述符。除了基本的<CR>,<ESC>,<SPACE>,<C-..>外,补充下列常用映射表:<k0>-<k9>小键盘数字0-9<BS>退格键backspace<S-...>代表shift<M-...>或<A-...>Windows和Linux下代表alt/meta键,在m......
  • 四、nvim配置文件
    这是一份没有插件的neovim配置。init.vimsource$HOME/.config/nvim/general/settings.vimsource$HOME/.config/nvim/general/appearance.vimsource$HOME/.config/nvim/general/keyshortcuts.vimsource$HOME/.config/nvim/general/plugins.vim下属四个子配置文件:(一)se......
  • IDEA 12大全局配置,快速提供开发效率
    IDEA相关配置整理于2024.06.0923:23@程序员猴哥1编码设置:File-->newprojectssettings-->settingsfornewprojects-->editor--->fileencodings-->globalencodeing:utf-8;projectencoding:utf-8;defaultencodingforpropertiesfiles:utf-8![img](file......
  • Nacos注册中心和配置中心
    1nacos简介1.1nacos介绍        Nacos是阿里的一个开源产品,它是针对微服务架构中的服务发现、配置管理、服务治理的综合型解决方案。是微服务的注册中心和配置中心,相当于springcloudEureka和springconfig的集合。    Nacos致力于帮助您发现、配置和管理......
  • mac python 包管理工具 pip 的配置
     python3--versionPython3.12.3brewinstallpython@3.12pip3configsetglobal.index-urlhttps://pypi.tuna.tsinghua.edu.cn/simplepip3configsetglobal.break-system-packagestrue pip3installaiohttppython包管理工具pip的配置 近几年来,python的包......
  • Macbook M芯片Maven的安装与配置
    MacbookM芯片Maven的安装与配置下载搜索Maven进入网站https://maven.apache.org/download.cgi点击Download点击如下链接进行下载;将下载好的文件放到你的指定位置双击进行解压配置环境变量进入终端在终端中输入open~/.bash_profile输入以下内容#mavenexportM......