*/}}

CMakeLists.txt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
  15. add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
  16. file(GLOB_RECURSE SOURCE_FILES
  17. ./*.c ./*.cpp ./resources/*.c ./resources/*.cpp)
  18. file(GLOB_RECURSE HEADER_FILES
  19. ./*.h ./*.hpp ./resources/*.h ./resources/*.hpp)
  20. add_definitions(-DLAGUI_FONT_CUSTOM_PATH=\"${LAGUI_FONT_CUSTOM_PATH}\")
  21. add_definitions(-w)
  22. include_directories(
  23. ${CMAKE_SOURCE_DIR}
  24. ${X11_INCLUDE_DIR}
  25. ${GLEW_INCLUDE_PATH}
  26. ${GLM_INCLUDE_PATH}
  27. ${FREETYPE_INCLUDE_DIRS}
  28. lagui
  29. )
  30. set(LAGUI_FONTS
  31. "fonts/NotoEmoji-Regular.ttf"
  32. "fonts/NotoSansCJK-Regular.ttc"
  33. "fonts/NotoSansMono-Regular.ttf"
  34. "fonts/NotoSansSymbols-Regular.ttf"
  35. "fonts/NotoSansSymbols2-Regular.ttf"
  36. )
  37. add_library(lagui ${HEADER_FILES} ${SOURCE_FILES})
  38. execute_process(
  39. COMMAND git rev-parse --abbrev-ref HEAD
  40. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  41. OUTPUT_VARIABLE LAGUI_GIT_BRANCH
  42. OUTPUT_STRIP_TRAILING_WHITESPACE)
  43. execute_process(
  44. COMMAND git rev-parse --short=12 HEAD
  45. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  46. OUTPUT_VARIABLE LAGUI_GIT_HASH
  47. OUTPUT_STRIP_TRAILING_WHITESPACE)
  48. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_BRANCH=\"${LAGUI_GIT_BRANCH}\"")
  49. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_HASH=\"${LAGUI_GIT_HASH}\"")
  50. install(FILES ${HEADER_FILES} DESTINATION include/lagui)
  51. install(TARGETS lagui EXPORT lagui-targets DESTINATION lib/lagui)
  52. install(EXPORT lagui-targets DESTINATION lib/lagui)
  53. install(FILES lagui-config.cmake DESTINATION lib/lagui)
  54. install(FILES ${LAGUI_FONTS} DESTINATION ${LAGUI_FONT_CUSTOM_PATH})