*/}}

CMakeLists.txt 3.4 KB

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