*/}}

CMakeLists.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
  11. find_package(OpenGL REQUIRED)
  12. find_package(X11 REQUIRED)
  13. find_package(Freetype REQUIRED)
  14. find_package(GLEW REQUIRED)
  15. find_package(LuaJIT REQUIRED)
  16. set(CMAKE_THREAD_PREFER_PTHREAD ON)
  17. set(THREADS_PREFER_PTHREAD_FLAG ON)
  18. find_package(Threads REQUIRED)
  19. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
  20. add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
  21. file(GLOB SOURCE_FILES
  22. ./*.c ./*.cpp ./resources/*.c ./resources/*.cpp)
  23. file(GLOB HEADER_FILES
  24. ./*.h ./*.hpp ./resources/*.h ./resources/*.hpp)
  25. add_definitions(-DLAGUI_FONT_CUSTOM_PATH=\"${LAGUI_FONT_CUSTOM_PATH}\")
  26. add_definitions(-w)
  27. include_directories(
  28. ${CMAKE_SOURCE_DIR}
  29. ${X11_INCLUDE_DIR}
  30. ${GLEW_INCLUDE_PATH}
  31. ${GLM_INCLUDE_PATH}
  32. ${FREETYPE_INCLUDE_DIRS}
  33. ${LUA_INCLUDE_DIR}
  34. lagui
  35. )
  36. if(WIN32)
  37. list(APPEND SOURCE_FILES ./wintab/wintab_utils.c)
  38. file(GLOB wintabfiles ./wintab/*.h )
  39. list(APPEND HEADER_FILES ${wintabfiles})
  40. include_directories(wintab)
  41. endif()
  42. list(APPEND SOURCE_FILES ./nanovg/nanovg.c)
  43. file(GLOB nvgfiles ./nanovg/*.h )
  44. list(APPEND HEADER_FILES ${nvgfiles})
  45. include_directories(nanovg)
  46. set(LAGUI_FONTS
  47. "fonts/NotoEmoji-Regular.ttf"
  48. "fonts/NotoSansCJK-Regular.ttc"
  49. "fonts/NotoSansMono-Regular.ttf"
  50. "fonts/NotoSansSymbols-Regular.ttf"
  51. "fonts/NotoSansSymbols2-Regular.ttf"
  52. )
  53. add_library(lagui ${HEADER_FILES} ${SOURCE_FILES})
  54. execute_process(
  55. COMMAND git rev-parse --abbrev-ref HEAD
  56. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  57. OUTPUT_VARIABLE LAGUI_GIT_BRANCH
  58. OUTPUT_STRIP_TRAILING_WHITESPACE)
  59. execute_process(
  60. COMMAND git rev-parse --short=12 HEAD
  61. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  62. OUTPUT_VARIABLE LAGUI_GIT_HASH
  63. OUTPUT_STRIP_TRAILING_WHITESPACE)
  64. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_BRANCH=\"${LAGUI_GIT_BRANCH}\"")
  65. target_compile_definitions(lagui PRIVATE "-DLAGUI_GIT_HASH=\"${LAGUI_GIT_HASH}\"")
  66. install(FILES ${HEADER_FILES} DESTINATION include/lagui)
  67. install(TARGETS lagui EXPORT lagui-targets DESTINATION lib/lagui)
  68. install(EXPORT lagui-targets DESTINATION lib/lagui)
  69. install(FILES lagui-config.cmake DESTINATION lib/lagui)
  70. install(FILES FindLuaJIT.cmake DESTINATION lib/lagui)
  71. install(FILES ${LAGUI_FONTS} DESTINATION ${LAGUI_FONT_CUSTOM_PATH})