CMakeLists.txt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # SPDX-License-Identifier: MIT
  2. cmake_minimum_required(VERSION 3.12.4)
  3. project(gui_guider)
  4. find_package(PkgConfig)
  5. pkg_check_modules(PKG_WAYLAND wayland-client wayland-cursor xkbcommon)
  6. pkg_check_modules(PKG_LIBDRM REQUIRED libdrm)
  7. # Wayland protocols
  8. find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
  9. pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.25)
  10. pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
  11. macro(wayland_generate protocol_xml_file output_dir target)
  12. set(output_file_noext "${output_dir}/wayland_xdg_shell")
  13. add_custom_command(OUTPUT "${output_file_noext}.h"
  14. COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_xml_file}" "${output_file_noext}.h"
  15. DEPENDS "${protocol_xml_file}"
  16. VERBATIM)
  17. add_custom_command(OUTPUT "${output_file_noext}.c"
  18. COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_xml_file}" "${output_file_noext}.c"
  19. DEPENDS "${protocol_xml_file}"
  20. VERBATIM)
  21. if(NOT EXISTS ${protocol_xml_file})
  22. message("Protocol XML file not found: " ${protocol_xml_file})
  23. else()
  24. set_property(TARGET ${target} APPEND PROPERTY SOURCES "${output_file_noext}.h" "${output_file_noext}.c")
  25. endif()
  26. endmacro()
  27. set(WAYLAND_PROTOCOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ports/linux/wl_protocols")
  28. file(MAKE_DIRECTORY ${WAYLAND_PROTOCOLS_DIR})
  29. add_custom_target(generate_protocols ALL)
  30. wayland_generate("${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml" ${WAYLAND_PROTOCOLS_DIR} generate_protocols)
  31. FILE(GLOB_RECURSE SOURCES ./custom/*.c ./generated/*.c ports/linux/mouse_cursor_icon.c ports/linux/main.c)
  32. add_executable (gui_guider ${SOURCES} ${WAYLAND_PROTOCOLS_DIR}/wayland_xdg_shell.c)
  33. if(EXISTS ${CMAKE_SOURCE_DIR}/lvgl)
  34. add_subdirectory(lvgl)
  35. target_include_directories(lvgl PRIVATE ${WAYLAND_PROTOCOLS_DIR})
  36. target_include_directories(lvgl PUBLIC ${PKG_LIBDRM_INCLUDE_DIRS})
  37. target_include_directories(gui_guider PRIVATE lvgl/src lvgl/src/font)
  38. endif()
  39. target_link_libraries (gui_guider PUBLIC lvgl ${PKG_WAYLAND_LIBRARIES} ${PKG_LIBDRM_LIBRARIES})
  40. target_include_directories(gui_guider PRIVATE generated custom generated/guider_customer_fonts generated/guider_fonts generated/images)
  41. install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/gui_guider DESTINATION bin)