*/}}
1
0

CMakeLists.txt 3.1 KB

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