*/}}

lagui-config.cmake 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # LaGUI CMake config file.
  2. get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
  3. include(${SELF_DIR}/lagui-targets.cmake)
  4. get_filename_component(LAGUI_INCLUDE_DIRS "${SELF_DIR}/../../include/lagui" ABSOLUTE)
  5. if (POLICY CMP0072)
  6. set(OpenGL_GL_PREFERENCE GLVND)
  7. endif()
  8. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
  9. SET(LAGUI_USE_GLES false CACHE BOOL "Whether to use GLES in LaGUI")
  10. if(${LAGUI_USE_GLES})
  11. add_definitions(-DLA_USE_GLES)
  12. set(LAGUI_GL_LIB ${OPENGL_egl_LIBRARY} ${OPENGL_gles2_LIBRARY} ${OPENGL_opengl_LIBRARY})
  13. else()
  14. set(LAGUI_GL_LIB ${OPENGL_glx_LIBRARY} ${OPENGL_opengl_LIBRARY})
  15. endif()
  16. find_package(OpenGL REQUIRED)
  17. find_package(X11 REQUIRED)
  18. find_package(Freetype REQUIRED)
  19. find_package(GLEW REQUIRED)
  20. find_package(PNG REQUIRED)
  21. find_package(LuaJIT REQUIRED)
  22. set(CMAKE_THREAD_PREFER_PTHREAD ON)
  23. set(THREADS_PREFER_PTHREAD_FLAG ON)
  24. find_package(Threads REQUIRED)
  25. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  26. set(LAGUI_SHARED_LIBS
  27. ${X11_LIBRARIES}
  28. ${X11_X11_LIB}
  29. ${GLEW_LIBRARIES}
  30. ${LAGUI_GL_LIB}
  31. ${FREETYPE_LIBRARIES}
  32. ${X11_Xfixes_LIB}
  33. ${X11_Xrandr_LIB}
  34. ${PNG_LIBRARY}
  35. m X11 Xi Xcursor
  36. ${CMAKE_DL_LIBS}
  37. Threads::Threads
  38. ${LUA_LIBRARY}
  39. lagui
  40. CACHE INTERNAL "LaGUI shared libs"
  41. )
  42. set(LAGUI_INCLUDE_DIRS_ALL
  43. ${CMAKE_SOURCE_DIR}
  44. ${X11_INCLUDE_DIR}
  45. ${GLEW_INCLUDE_PATH}
  46. ${FREETYPE_INCLUDE_DIRS}
  47. ${LAGUI_INCLUDE_DIRS}
  48. ${LUA_INCLUDE_DIR}
  49. CACHE INTERNAL "Include dirs of LaGUI and dependencies"
  50. )
  51. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  52. set(LAGUI_SHARED_LIBS
  53. ${GLEW_LIBRARIES}
  54. ${OPENGL_LIBRARY}
  55. ${FREETYPE_LIBRARIES}
  56. ${PNG_LIBRARY}
  57. ${CMAKE_DL_LIBS}
  58. ${LUA_LIBRARY}
  59. Threads::Threads
  60. lagui shlwapi
  61. CACHE INTERNAL "LaGUI shared libs"
  62. )
  63. set(LAGUI_INCLUDE_DIRS_ALL
  64. ${CMAKE_SOURCE_DIR}
  65. ${GLEW_INCLUDE_PATH}
  66. ${FREETYPE_INCLUDE_DIRS}
  67. ${LAGUI_INCLUDE_DIRS}
  68. ${LUA_INCLUDE_DIR}
  69. CACHE INTERNAL "Include dirs of LaGUI and dependencies"
  70. )
  71. endif()
  72. # Build Types
  73. set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
  74. CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel tnsan asan lsan msan ubsan"
  75. FORCE)
  76. # ThreadSanitizer
  77. set(CMAKE_C_FLAGS_TSAN
  78. "-fsanitize=thread -g -O1"
  79. CACHE STRING "Flags used by the C compiler during ThreadSanitizer builds."
  80. FORCE)
  81. set(CMAKE_CXX_FLAGS_TSAN
  82. "-fsanitize=thread -g -O1"
  83. CACHE STRING "Flags used by the C++ compiler during ThreadSanitizer builds."
  84. FORCE)
  85. # AddressSanitize
  86. set(CMAKE_C_FLAGS_ASAN
  87. "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g"
  88. CACHE STRING "Flags used by the C compiler during AddressSanitizer builds."
  89. FORCE)
  90. set(CMAKE_CXX_FLAGS_ASAN
  91. "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g"
  92. CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds."
  93. FORCE)
  94. # LeakSanitizer
  95. set(CMAKE_C_FLAGS_LSAN
  96. "-fsanitize=leak -fno-omit-frame-pointer -g"
  97. CACHE STRING "Flags used by the C compiler during LeakSanitizer builds."
  98. FORCE)
  99. set(CMAKE_CXX_FLAGS_LSAN
  100. "-fsanitize=leak -fno-omit-frame-pointer -g"
  101. CACHE STRING "Flags used by the C++ compiler during LeakSanitizer builds."
  102. FORCE)
  103. # MemorySanitizer
  104. set(CMAKE_C_FLAGS_MSAN
  105. "-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g"
  106. CACHE STRING "Flags used by the C compiler during MemorySanitizer builds."
  107. FORCE)
  108. set(CMAKE_CXX_FLAGS_MSAN
  109. "-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g"
  110. CACHE STRING "Flags used by the C++ compiler during MemorySanitizer builds."
  111. FORCE)
  112. # UndefinedBehaviour
  113. set(CMAKE_C_FLAGS_UBSAN
  114. "-fsanitize=undefined"
  115. CACHE STRING "Flags used by the C compiler during UndefinedBehaviourSanitizer builds."
  116. FORCE)
  117. set(CMAKE_CXX_FLAGS_UBSAN
  118. "-fsanitize=undefined"
  119. CACHE STRING "Flags used by the C++ compiler during UndefinedBehaviourSanitizer builds."
  120. FORCE)
  121. set(LAGUI_FONTS
  122. "NotoEmoji-Regular.ttf"
  123. "NotoSansCJK-Regular.ttc"
  124. "NotoSansMono-Regular.ttf"
  125. "NotoSansSymbols-Regular.ttf"
  126. "NotoSansSymbols2-Regular.ttf"
  127. )