CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. cmake_minimum_required(VERSION 3.14)
  2. project(Megapixels C)
  3. set(CMAKE_C_STANDARD 11)
  4. # Use the package PkgConfig to detect GTK+ headers/library files
  5. FIND_PACKAGE(PkgConfig REQUIRED)
  6. PKG_CHECK_MODULES(GTK4 REQUIRED gtk4)
  7. PKG_CHECK_MODULES(FEEDBACK REQUIRED libfeedback-0.0)
  8. PKG_CHECK_MODULES(TIFF REQUIRED libtiff-4)
  9. PKG_CHECK_MODULES(ZBAR REQUIRED zbar)
  10. PKG_CHECK_MODULES(EPOXY REQUIRED epoxy)
  11. PKG_CHECK_MODULES(MEGAPIXELS REQUIRED libmegapixels)
  12. PKG_CHECK_MODULES(DNG REQUIRED libdng)
  13. PKG_CHECK_MODULES(XLIB REQUIRED x11)
  14. PKG_CHECK_MODULES(XRANDR REQUIRED xrandr)
  15. PKG_CHECK_MODULES(WAYLAND REQUIRED wayland-client)
  16. PKG_CHECK_MODULES(JPEG REQUIRED libjpeg)
  17. # Setup CMake to use GTK+, tell the compiler where to look for headers
  18. # and to the linker where to look for libraries
  19. INCLUDE_DIRECTORIES(
  20. ${GTK4_INCLUDE_DIRS}
  21. ${FEEDBACK_INCLUDE_DIRS}
  22. ${DNG_INCLUDE_DIRS}
  23. ${ZBAR_INCLUDE_DIRS}
  24. ${EPOXY_INCLUDE_DIRS}
  25. ${MEGAPIXELS_INCLUDE_DIRS}
  26. ${XLIB_INCLUDE_DIRS}
  27. ${XRANDR_INCLUDE_DIRS}
  28. ${WAYLAND_INCLUDE_DIRS}
  29. ${JPEG_INCLUDE_DIRS}
  30. )
  31. LINK_DIRECTORIES(
  32. ${GTK4_LIBRARY_DIRS}
  33. ${FEEDBACK_LIBRARY_DIRS}
  34. ${DNG_LIBRARY_DIRS}
  35. ${ZBAR_LIBRARY_DIRS}
  36. ${EPOXY_LIBRARY_DIRS}
  37. ${MEGAPIXELS_LIBRARY_DIRS}
  38. ${XLIB_LIBRARY_DIRS}
  39. ${XRANDR_LIBRARY_DIRS}
  40. ${WAYLAND_LIBRARY_DIRS}
  41. ${JPEG_DIRS}
  42. )
  43. # Add other flags to the compiler
  44. ADD_DEFINITIONS(
  45. ${GTK4_CFLAGS_OTHER}
  46. ${FEEDBACK_CFLAGS_OTHER}
  47. ${DNG_CFLAGS_OTHER}
  48. ${ZBAR_CFLAGS_OTHER}
  49. ${EPOXY_CFLAGS_OTHER}
  50. ${MEGAPIXELS_CFLAGS_OTHER}
  51. ${XLIB_CFLAGS_OTHER}
  52. ${XRANDR_CFLAGS_OTHER}
  53. ${WAYLAND_CFLAGS_OTHER}
  54. ${JPEG_OTHER}
  55. )
  56. find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED)
  57. set(GRESOURCE_C megapixels.gresource.c)
  58. set(GRESOURCE_XML data/me.gapixels.Megapixels.gresource.xml)
  59. add_custom_command(
  60. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
  61. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
  62. COMMAND ${GLIB_COMPILE_RESOURCES}
  63. ARGS
  64. --generate-source
  65. --target=${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
  66. ../${GRESOURCE_XML}
  67. VERBATIM
  68. MAIN_DEPENDENCY ${GRESOURCE_XML}
  69. )
  70. add_custom_target(
  71. dummy-resource
  72. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
  73. )
  74. file(GLOB srcs src/*.c src/*h)
  75. add_executable(megapixels-gtk ${srcs} medianame.h ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} src/state.h)
  76. set_source_files_properties(
  77. ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
  78. PROPERTIES GENERATED TRUE
  79. )
  80. add_dependencies(megapixels-gtk dummy-resource)
  81. target_link_libraries(megapixels-gtk
  82. m
  83. ${GTK4_LIBRARIES}
  84. ${FEEDBACK_LIBRARIES}
  85. ${DNG_LIBRARIES}
  86. ${ZBAR_LIBRARIES}
  87. ${EPOXY_LIBRARIES}
  88. ${MEGAPIXELS_LIBRARIES}
  89. ${XLIB_LIBRARIES}
  90. ${XRANDR_LIBRARIES}
  91. ${WAYLAND_LIBRARIES}
  92. ${JPEG_LIBRARIES}
  93. )
  94. add_compile_definitions(VERSION="${PROJECT_VERSION}")
  95. add_compile_definitions(SYSCONFDIR="/etc")
  96. add_compile_definitions(DATADIR="/usr/share")