*/}}

CMakeLists.txt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. cmake_minimum_required(VERSION 3.1)
  2. project (lagui)
  3. if (POLICY CMP0072)
  4. set(OpenGL_GL_PREFERENCE GLVND)
  5. endif()
  6. SET(LAGUI_FONT_CUSTOM_PATH $ENV{HOME}/.local/share/fonts/lagui CACHE STRING "Where to install lagui fonts")
  7. if (NOT DEFINED ${LAGUI_FONT_CUSTOM_PATH})
  8. set(LAGUI_FONT_CUSTOM_PATH $ENV{HOME}/.local/share/fonts/lagui)
  9. endif()
  10. find_package(OpenGL REQUIRED)
  11. find_package(X11 REQUIRED)
  12. find_package(Freetype REQUIRED)
  13. find_package(GLEW REQUIRED)
  14. file(GLOB_RECURSE SOURCE_FILES
  15. ./*.c ./*.cpp ./resources/*.c ./resources/*.cpp)
  16. file(GLOB_RECURSE HEADER_FILES
  17. ./*.h ./*.hpp ./resources/*.h ./resources/*.hpp)
  18. add_definitions(-DLAGUI_FONT_CUSTOM_PATH=\"${LAGUI_FONT_CUSTOM_PATH}\")
  19. add_definitions(-w)
  20. include_directories(
  21. ${CMAKE_SOURCE_DIR}
  22. ${X11_INCLUDE_DIR}
  23. ${GLEW_INCLUDE_PATH}
  24. ${GLM_INCLUDE_PATH}
  25. ${FREETYPE_INCLUDE_DIRS}
  26. lagui
  27. )
  28. set(LAGUI_FONTS
  29. "fonts/NotoEmoji-Regular.ttf"
  30. "fonts/NotoSansCJK-Regular.ttc"
  31. "fonts/NotoSansMono-Regular.ttf"
  32. "fonts/NotoSansSymbols-Regular.ttf"
  33. "fonts/NotoSansSymbols2-Regular.ttf"
  34. )
  35. add_library(lagui ${HEADER_FILES} ${SOURCE_FILES})
  36. execute_process(
  37. COMMAND git rev-parse --abbrev-ref HEAD
  38. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  39. OUTPUT_VARIABLE LAGUI_GIT_BRANCH
  40. OUTPUT_STRIP_TRAILING_WHITESPACE)
  41. execute_process(
  42. COMMAND git rev-parse --short=12 HEAD
  43. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  44. OUTPUT_VARIABLE LAGUI_GIT_HASH
  45. OUTPUT_STRIP_TRAILING_WHITESPACE)
  46. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_BRANCH=\"${LAGUI_GIT_BRANCH}\"")
  47. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_HASH=\"${LAGUI_GIT_HASH}\"")
  48. install(FILES ${HEADER_FILES} DESTINATION include/lagui)
  49. install(TARGETS lagui EXPORT lagui-targets DESTINATION lib/lagui)
  50. install(EXPORT lagui-targets DESTINATION lib/lagui)
  51. install(FILES lagui-config.cmake DESTINATION lib/lagui)
  52. install(FILES ${LAGUI_FONTS} DESTINATION ${LAGUI_FONT_CUSTOM_PATH})