*/}}
1
0

CMakeLists.txt 3.2 KB

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