*/}}

lagui-config.cmake 5.2 KB

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