2023-11-09 07:31:26 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2021-01-15 09:30:03 +00:00
|
|
|
project(displayservers LANGUAGES C)
|
|
|
|
|
|
|
|
set(DISPLAYSERVER_H "${CMAKE_BINARY_DIR}/include/dynamic/displayservers.h")
|
|
|
|
set(DISPLAYSERVER_C "${CMAKE_BINARY_DIR}/src/displayservers.c")
|
|
|
|
|
|
|
|
file(WRITE ${DISPLAYSERVER_H} "#include \"interface/displayserver.h\"\n\n")
|
|
|
|
file(APPEND ${DISPLAYSERVER_H} "extern struct LG_DisplayServerOps * LG_DisplayServers[];\n\n")
|
|
|
|
|
|
|
|
file(WRITE ${DISPLAYSERVER_C} "#include \"interface/displayserver.h\"\n\n")
|
|
|
|
file(APPEND ${DISPLAYSERVER_C} "#include <stddef.h>\n\n")
|
|
|
|
|
|
|
|
set(DISPLAYSERVERS "_")
|
|
|
|
set(DISPLAYSERVERS_LINK "_")
|
|
|
|
function(add_displayserver name)
|
|
|
|
set(DISPLAYSERVERS "${DISPLAYSERVERS};${name}" PARENT_SCOPE)
|
|
|
|
set(DISPLAYSERVERS_LINK "${DISPLAYSERVERS_LINK};displayserver_${name}" PARENT_SCOPE)
|
|
|
|
add_subdirectory(${name})
|
|
|
|
endfunction()
|
|
|
|
|
2024-03-13 00:17:25 +00:00
|
|
|
option(ENABLE_X11 "Build with X11 support" ON)
|
|
|
|
add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.")
|
|
|
|
|
2023-11-09 05:30:27 +00:00
|
|
|
option(ENABLE_WAYLAND "Build with Wayland support" ON)
|
|
|
|
add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland support.")
|
|
|
|
|
2024-03-13 00:17:25 +00:00
|
|
|
if (NOT ENABLE_X11 AND NOT ENABLE_WAYLAND)
|
|
|
|
message(FATAL_ERROR "Either ENABLE_X11 or ENABLE_WAYLAND must be on")
|
|
|
|
endif()
|
|
|
|
|
2021-01-15 09:30:03 +00:00
|
|
|
# Add/remove displayservers here!
|
|
|
|
if (ENABLE_WAYLAND)
|
|
|
|
add_displayserver(Wayland)
|
|
|
|
endif()
|
|
|
|
|
2021-01-27 05:43:01 +00:00
|
|
|
if (ENABLE_X11)
|
|
|
|
add_displayserver(X11)
|
|
|
|
endif()
|
|
|
|
|
2021-01-15 09:30:03 +00:00
|
|
|
list(REMOVE_AT DISPLAYSERVERS 0)
|
|
|
|
list(REMOVE_AT DISPLAYSERVERS_LINK 0)
|
|
|
|
|
|
|
|
list(LENGTH DISPLAYSERVERS DISPLAYSERVER_COUNT)
|
|
|
|
file(APPEND ${DISPLAYSERVER_H} "#define LG_DISPLAYSERVER_COUNT ${DISPLAYSERVER_COUNT}\n")
|
|
|
|
|
|
|
|
foreach(displayserver ${DISPLAYSERVERS})
|
|
|
|
file(APPEND ${DISPLAYSERVER_C} "extern struct LG_DisplayServerOps LGDS_${displayserver};\n")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
file(APPEND ${DISPLAYSERVER_C} "\nconst struct LG_DisplayServerOps * LG_DisplayServers[] =\n{\n")
|
|
|
|
foreach(displayserver ${DISPLAYSERVERS})
|
|
|
|
file(APPEND ${DISPLAYSERVER_C} " &LGDS_${displayserver},\n")
|
|
|
|
endforeach()
|
|
|
|
file(APPEND ${DISPLAYSERVER_C} " NULL\n};")
|
|
|
|
|
|
|
|
add_library(displayservers STATIC ${DISPLAYSERVER_C})
|
|
|
|
target_link_libraries(displayservers ${DISPLAYSERVERS_LINK})
|