CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. cmake_minimum_required(VERSION 3.13)
  2. project(libjpeg LANGUAGES C)
  3. option(BUILD_EXECUTABLES OFF)
  4. #
  5. # jconfig.h is a public header, so it must be genrated. Please reference the install.txt in jpegsr9d.zip
  6. #
  7. # jconfig.txt should contain #cmakedefine which is modified by porfile.cmake of ijg-libjpeg port in VcPkg
  8. # By doing this we can skip 'configure' step. Visit https://github.com/LuaDist/libjpeg
  9. #
  10. include(CheckIncludeFile)
  11. check_include_file(stddef.h HAVE_STDDEF_H)
  12. check_include_file(stdlib.h HAVE_STDLIB_H)
  13. configure_file(jconfig.txt ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h)
  14. list(APPEND PUBLIC_HEADERS jpeglib.h jerror.h jmorecfg.h ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h)
  15. add_library(jpeg
  16. ${PUBLIC_HEADERS} jinclude.h jpegint.h jversion.h
  17. transupp.h jidctflt.c jidctfst.c jidctint.c jquant1.c jquant2.c jutils.c jmemnobs.c jaricom.c jerror.c jdatadst.c jdatasrc.c
  18. jmemsys.h
  19. jmemmgr.c
  20. cdjpeg.h cderror.h
  21. jcmaster.c jcmarker.c jcmainct.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c jcsample.c jctrans.c jcinit.c jcomapi.c jcparam.c jcprepct.c
  22. jdmaster.c jdmarker.c jdmainct.c jdapimin.c jdapistd.c jdarith.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdsample.c jdtrans.c jdinput.c jdmerge.c jdpostct.c
  23. jdct.h
  24. jfdctflt.c jfdctfst.c jfdctint.c
  25. )
  26. if(WIN32)
  27. target_compile_definitions(jpeg
  28. PRIVATE
  29. _CRT_SECURE_NO_WARNINGS
  30. )
  31. endif()
  32. target_include_directories(jpeg PRIVATE include ${CMAKE_CURRENT_BINARY_DIR})
  33. install(FILES ${PUBLIC_HEADERS}
  34. DESTINATION ${CMAKE_INSTALL_PREFIX}/include
  35. )
  36. install(TARGETS jpeg
  37. RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
  38. LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  39. ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  40. )
  41. if(BUILD_EXECUTABLES)
  42. add_executable(cjpeg cdjpeg.c cjpeg.c rdbmp.c rdgif.c rdppm.c rdrle.c rdtarga.c rdswitch.c)
  43. target_link_libraries(cjpeg PRIVATE jpeg)
  44. add_executable(djpeg cdjpeg.c djpeg.c wrbmp.c wrgif.c wrppm.c wrrle.c wrtarga.c rdcolmap.c)
  45. target_link_libraries(djpeg PRIVATE jpeg)
  46. add_executable(jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c)
  47. target_link_libraries(jpegtran PRIVATE jpeg)
  48. add_executable(rdjpgcom rdjpgcom.c)
  49. add_executable(wrjpgcom wrjpgcom.c)
  50. install(TARGETS cjpeg djpeg jpegtran rdjpgcom wrjpgcom
  51. DESTINATION ${CMAKE_INSTALL_PREFIX}/tools
  52. )
  53. endif()