*/}}
1
0

CMakeLists.txt 2.7 KB

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