*/}}

lagui-config.cmake 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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)
  21. find_package(LuaJIT)
  22. if (APPLE)
  23. find_package(GLFW3 REQUIRED)
  24. endif()
  25. set(CMAKE_THREAD_PREFER_PTHREAD ON)
  26. set(THREADS_PREFER_PTHREAD_FLAG ON)
  27. find_package(Threads REQUIRED)
  28. SET(LAGUI_USE_LUAJIT true CACHE BOOL "Whether to use LuaJIT in LaGUI")
  29. if(${LuaJIT_FOUND} AND ${LAGUI_USE_LUAJIT})
  30. add_definitions(-DLA_WITH_LUAJIT)
  31. endif()
  32. SET(LAGUI_USE_PNG true CACHE BOOL "Whether to use LuaJIT in LaGUI")
  33. if(${PNG_FOUND} AND ${LAGUI_USE_PNG})
  34. add_definitions(-DLA_WITH_PNG)
  35. endif()
  36. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  37. set(LAGUI_SHARED_LIBS
  38. ${OPENGL_LIBRARY}
  39. ${X11_LIBRARIES}
  40. ${X11_X11_LIB}
  41. ${GLEW_LIBRARIES}
  42. ${LAGUI_GL_LIB}
  43. ${FREETYPE_LIBRARIES}
  44. ${X11_Xfixes_LIB}
  45. ${X11_Xrandr_LIB}
  46. m X11 Xi Xcursor
  47. ${CMAKE_DL_LIBS}
  48. Threads::Threads
  49. ${LUA_LIBRARY}
  50. lagui
  51. CACHE INTERNAL "LaGUI shared libs"
  52. )
  53. set(LAGUI_INCLUDE_DIRS_ALL
  54. ${OPENGL_LIBRARY}
  55. ${CMAKE_SOURCE_DIR}
  56. ${X11_INCLUDE_DIR}
  57. ${GLEW_INCLUDE_PATH}
  58. ${FREETYPE_INCLUDE_DIRS}
  59. ${LAGUI_INCLUDE_DIRS}
  60. CACHE INTERNAL "Include dirs of LaGUI and dependencies"
  61. )
  62. if(${LuaJIT_FOUND})
  63. list(APPEND LAGUI_SHARED_LIBS ${LUA_LIBRARY})
  64. list(APPEND LAGUI_INCLUDE_DIRS_ALL ${LUA_INCLUDE_DIR})
  65. endif()
  66. if(${PNG_FOUND})
  67. list(APPEND LAGUI_SHARED_LIBS ${PNG_LIBRARY})
  68. list(APPEND LAGUI_INCLUDE_DIRS_ALL ${PNG_INCLUDE_DIR})
  69. endif()
  70. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  71. set(LAGUI_SHARED_LIBS
  72. ${OPENGL_LIBRARY}
  73. ${GLEW_LIBRARIES}
  74. ${LAGUI_GL_LIB}
  75. ${FREETYPE_LIBRARIES}
  76. m
  77. ${GLFW3_LIBRARIES}
  78. ${CMAKE_DL_LIBS}
  79. Threads::Threads
  80. ${LUA_LIBRARY}
  81. lagui
  82. CACHE INTERNAL "LaGUI shared libs"
  83. )
  84. set(LAGUI_INCLUDE_DIRS_ALL
  85. ${OPENGL_LIBRARY}
  86. ${CMAKE_SOURCE_DIR}
  87. ${GLEW_INCLUDE_PATH}
  88. ${FREETYPE_INCLUDE_DIRS}
  89. ${LAGUI_INCLUDE_DIRS}
  90. CACHE INTERNAL "Include dirs of LaGUI and dependencies"
  91. )
  92. if(${LuaJIT_FOUND})
  93. list(APPEND LAGUI_SHARED_LIBS ${LUA_LIBRARY})
  94. list(APPEND LAGUI_INCLUDE_DIRS_ALL ${LUA_INCLUDE_DIR})
  95. endif()
  96. if(${PNG_FOUND})
  97. list(APPEND LAGUI_SHARED_LIBS ${PNG_LIBRARY})
  98. list(APPEND LAGUI_INCLUDE_DIRS_ALL ${PNG_INCLUDE_DIR})
  99. endif()
  100. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  101. set(LAGUI_SHARED_LIBS
  102. ${GLEW_LIBRARIES}
  103. ${OPENGL_LIBRARY}
  104. ${FREETYPE_LIBRARIES}
  105. ${CMAKE_DL_LIBS}
  106. Threads::Threads
  107. lagui shlwapi Shcore
  108. CACHE INTERNAL "LaGUI shared libs"
  109. )
  110. set(LAGUI_INCLUDE_DIRS_ALL
  111. ${CMAKE_SOURCE_DIR}
  112. ${GLEW_INCLUDE_PATH}
  113. ${FREETYPE_INCLUDE_DIRS}
  114. ${LAGUI_INCLUDE_DIRS}
  115. CACHE INTERNAL "Include dirs of LaGUI and dependencies"
  116. )
  117. if(${LuaJIT_FOUND})
  118. list(APPEND LAGUI_SHARED_LIBS ${LUA_LIBRARY})
  119. list(APPEND LAGUI_INCLUDE_DIRS_ALL ${LUA_INCLUDE_DIR})
  120. endif()
  121. if(${PNG_FOUND})
  122. list(APPEND LAGUI_SHARED_LIBS ${PNG_LIBRARY})
  123. list(APPEND LAGUI_INCLUDE_DIRS_ALL ${PNG_INCLUDE_DIR})
  124. endif()
  125. endif()
  126. # Build Types
  127. set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
  128. CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel tnsan asan lsan msan ubsan"
  129. FORCE)
  130. # ThreadSanitizer
  131. set(CMAKE_C_FLAGS_TSAN
  132. "-fsanitize=thread -g -O1"
  133. CACHE STRING "Flags used by the C compiler during ThreadSanitizer builds."
  134. FORCE)
  135. set(CMAKE_CXX_FLAGS_TSAN
  136. "-fsanitize=thread -g -O1"
  137. CACHE STRING "Flags used by the C++ compiler during ThreadSanitizer builds."
  138. FORCE)
  139. # AddressSanitize
  140. set(CMAKE_C_FLAGS_ASAN
  141. "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g"
  142. CACHE STRING "Flags used by the C compiler during AddressSanitizer builds."
  143. FORCE)
  144. set(CMAKE_CXX_FLAGS_ASAN
  145. "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g"
  146. CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds."
  147. FORCE)
  148. # LeakSanitizer
  149. set(CMAKE_C_FLAGS_LSAN
  150. "-fsanitize=leak -fno-omit-frame-pointer -g"
  151. CACHE STRING "Flags used by the C compiler during LeakSanitizer builds."
  152. FORCE)
  153. set(CMAKE_CXX_FLAGS_LSAN
  154. "-fsanitize=leak -fno-omit-frame-pointer -g"
  155. CACHE STRING "Flags used by the C++ compiler during LeakSanitizer builds."
  156. FORCE)
  157. # MemorySanitizer
  158. set(CMAKE_C_FLAGS_MSAN
  159. "-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g"
  160. CACHE STRING "Flags used by the C compiler during MemorySanitizer builds."
  161. FORCE)
  162. set(CMAKE_CXX_FLAGS_MSAN
  163. "-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g"
  164. CACHE STRING "Flags used by the C++ compiler during MemorySanitizer builds."
  165. FORCE)
  166. # UndefinedBehaviour
  167. set(CMAKE_C_FLAGS_UBSAN
  168. "-fsanitize=undefined"
  169. CACHE STRING "Flags used by the C compiler during UndefinedBehaviourSanitizer builds."
  170. FORCE)
  171. set(CMAKE_CXX_FLAGS_UBSAN
  172. "-fsanitize=undefined"
  173. CACHE STRING "Flags used by the C++ compiler during UndefinedBehaviourSanitizer builds."
  174. FORCE)
  175. set(LAGUI_FONTS
  176. "NotoEmoji-Regular.ttf"
  177. "NotoSansCJK-Regular.ttc"
  178. "NotoSansMono-Regular.ttf"
  179. "NotoSansSymbols-Regular.ttf"
  180. "NotoSansSymbols2-Regular.ttf"
  181. )