*/}}

CMakeLists.txt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 SOURCE_FILES
  17. ./*.c ./*.cpp ./resources/*.c ./resources/*.cpp)
  18. file(GLOB 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. if(WIN32)
  31. list(APPEND SOURCE_FILES ./wintab/wintab_utils.c)
  32. file(GLOB wintabfiles ./wintab/*.h )
  33. list(APPEND HEADER_FILES ${wintabfiles})
  34. include_directories(wintab)
  35. endif()
  36. list(APPEND SOURCE_FILES ./nanovg/nanovg.c)
  37. file(GLOB nvgfiles ./nanovg/*.h )
  38. list(APPEND HEADER_FILES ${nvgfiles})
  39. include_directories(nanovg)
  40. set(LAGUI_FONTS
  41. "fonts/NotoEmoji-Regular.ttf"
  42. "fonts/NotoSansCJK-Regular.ttc"
  43. "fonts/NotoSansMono-Regular.ttf"
  44. "fonts/NotoSansSymbols-Regular.ttf"
  45. "fonts/NotoSansSymbols2-Regular.ttf"
  46. )
  47. add_library(lagui ${HEADER_FILES} ${SOURCE_FILES})
  48. execute_process(
  49. COMMAND git rev-parse --abbrev-ref HEAD
  50. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  51. OUTPUT_VARIABLE LAGUI_GIT_BRANCH
  52. OUTPUT_STRIP_TRAILING_WHITESPACE)
  53. execute_process(
  54. COMMAND git rev-parse --short=12 HEAD
  55. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  56. OUTPUT_VARIABLE LAGUI_GIT_HASH
  57. OUTPUT_STRIP_TRAILING_WHITESPACE)
  58. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_BRANCH=\"${LAGUI_GIT_BRANCH}\"")
  59. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_HASH=\"${LAGUI_GIT_HASH}\"")
  60. install(FILES ${HEADER_FILES} DESTINATION include/lagui)
  61. install(TARGETS lagui EXPORT lagui-targets DESTINATION lib/lagui)
  62. install(EXPORT lagui-targets DESTINATION lib/lagui)
  63. install(FILES lagui-config.cmake DESTINATION lib/lagui)
  64. install(FILES ${LAGUI_FONTS} DESTINATION ${LAGUI_FONT_CUSTOM_PATH})