*/}}

lagui-config.cmake 5.2 KB

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