From fdaede836ccbb7d7bfbe818f79e394f90ceff837 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 2 Mar 2020 16:18:26 -0600 Subject: [PATCH] build: Make it possible to turn off the main compositor lib and runtime target. --- CMakeLists.txt | 5 ++ src/xrt/compositor/CMakeLists.txt | 113 +++++++++++++++--------------- src/xrt/targets/CMakeLists.txt | 4 +- 3 files changed, 66 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7bdb4699..3bbc8177b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,11 @@ cmake_dependent_option(BUILD_WITH_XLIB "Enable xlib support" ON "X11_FOUND" OFF) cmake_dependent_option(BUILD_WITH_XCB "Enable xcb support" ON "XCB_FOUND" OFF) cmake_dependent_option(BUILD_WITH_OPENGL "Enable OpenGL Graphics API support" ON "OPENGL_FOUND" OFF) cmake_dependent_option(BUILD_WITH_EGL "Enable OpenGL on EGL Graphics API support" ON "BUILD_WITH_OPENGL AND EGL_FOUND" OFF) +cmake_dependent_option(BUILD_COMPOSITOR_MAIN "Build main compositor host" ON "BUILD_WITH_WAYLAND OR BUILD_WITH_XCB" OFF) +cmake_dependent_option(BUILD_TARGET_OPENXR "Build OpenXR runtime target" ON "BUILD_COMPOSITOR_MAIN" OFF) + +# Most users won't touch these. +mark_as_advanced(BUILD_COMPOSITOR_MAIN BUILD_TARGET_OPENXR) set(BUILD_WITH_LIBUSB TRUE) cmake_dependent_option(BUILD_WITH_JPEG "Enable jpeg code (used for some video drivers)" ON "JPEG_FOUND" OFF) diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt index e28826b99..3469f5062 100644 --- a/src/xrt/compositor/CMakeLists.txt +++ b/src/xrt/compositor/CMakeLists.txt @@ -82,60 +82,63 @@ add_library(comp_client OBJECT ${CLIENT_SOURCE_FILES}) # Main library # -if(BUILD_WITH_XCB) - list(APPEND MAIN_SOURCE_FILES - main/comp_window_xcb.cpp +if(BUILD_COMPOSITOR_MAIN) + + if(BUILD_WITH_XCB) + list(APPEND MAIN_SOURCE_FILES + main/comp_window_xcb.cpp + ) + endif() + if(BUILD_WITH_XCB AND BUILD_WITH_XLIB) + list(APPEND MAIN_SOURCE_FILES + main/comp_window_direct_mode.cpp + ) + endif() + + # generate wayland protocols + if(BUILD_WITH_WAYLAND) + pkg_get_variable(WL_PROTOS_PKG_DIR wayland-protocols pkgdatadir) + pkg_get_variable(WL_SCANNER wayland-scanner wayland_scanner) + + set(WL_PROTOS_DIR "${CMAKE_CURRENT_BINARY_DIR}/wayland-protocols/") + file(MAKE_DIRECTORY "${WL_PROTOS_DIR}") + + set(WL_PROTOS_XML "${WL_PROTOS_PKG_DIR}/stable/xdg-shell/xdg-shell.xml") + set(WL_PROTOS_C "${WL_PROTOS_DIR}/xdg-shell.c") + set(WL_PROTOS_H "${WL_PROTOS_DIR}/xdg-shell-client-protocol.h") + + add_custom_command( + COMMAND + ${WL_SCANNER} private-code "${WL_PROTOS_XML}" "${WL_PROTOS_C}" + OUTPUT "${WL_PROTOS_C}" VERBATIM) + + add_custom_command( + COMMAND + ${WL_SCANNER} client-header "${WL_PROTOS_XML}" "${WL_PROTOS_H}" + OUTPUT "${WL_PROTOS_H}" VERBATIM) + + set(WL_PROTOS_SRC ${WL_PROTOS_C} ${WL_PROTOS_H}) + list(APPEND MAIN_SOURCE_FILES + main/comp_window_wayland.c + ) + endif() + + # Use OBJECT to not create a archive, since it just gets in the way. + add_library(comp_main OBJECT ${SHADER_HEADERS} ${MAIN_SOURCE_FILES} ${WL_PROTOS_SRC}) + target_include_directories(comp_main SYSTEM PRIVATE + # Shaders - marked SYSTEM so we get no warnings + ${CMAKE_CURRENT_BINARY_DIR} ) + + if(BUILD_WITH_WAYLAND) + target_include_directories(comp_main SYSTEM PRIVATE ${WL_PROTOS_DIR}) + endif() + if(BUILD_WITH_XCB) + target_include_directories(comp_main SYSTEM PRIVATE ${XCB_INCLUDE_DIRS}) + endif() + if(BUILD_WITH_EGL) + target_include_directories(comp_main SYSTEM PRIVATE ${EGL_INCLUDE_DIRS}) + endif() + + add_subdirectory(shaders) endif() -if(BUILD_WITH_XCB AND BUILD_WITH_XLIB) - list(APPEND MAIN_SOURCE_FILES - main/comp_window_direct_mode.cpp - ) -endif() - -# generate wayland protocols -if(BUILD_WITH_WAYLAND) - pkg_get_variable(WL_PROTOS_PKG_DIR wayland-protocols pkgdatadir) - pkg_get_variable(WL_SCANNER wayland-scanner wayland_scanner) - - set(WL_PROTOS_DIR "${CMAKE_CURRENT_BINARY_DIR}/wayland-protocols/") - file(MAKE_DIRECTORY "${WL_PROTOS_DIR}") - - set(WL_PROTOS_XML "${WL_PROTOS_PKG_DIR}/stable/xdg-shell/xdg-shell.xml") - set(WL_PROTOS_C "${WL_PROTOS_DIR}/xdg-shell.c") - set(WL_PROTOS_H "${WL_PROTOS_DIR}/xdg-shell-client-protocol.h") - - add_custom_command( - COMMAND - ${WL_SCANNER} private-code "${WL_PROTOS_XML}" "${WL_PROTOS_C}" - OUTPUT "${WL_PROTOS_C}" VERBATIM) - - add_custom_command( - COMMAND - ${WL_SCANNER} client-header "${WL_PROTOS_XML}" "${WL_PROTOS_H}" - OUTPUT "${WL_PROTOS_H}" VERBATIM) - - set(WL_PROTOS_SRC ${WL_PROTOS_C} ${WL_PROTOS_H}) - list(APPEND MAIN_SOURCE_FILES - main/comp_window_wayland.c - ) -endif() - -# Use OBJECT to not create a archive, since it just gets in the way. -add_library(comp_main OBJECT ${SHADER_HEADERS} ${MAIN_SOURCE_FILES} ${WL_PROTOS_SRC}) -target_include_directories(comp_main SYSTEM PRIVATE - # Shaders - marked SYSTEM so we get no warnings - ${CMAKE_CURRENT_BINARY_DIR} - ) - -if(BUILD_WITH_WAYLAND) - target_include_directories(comp_main SYSTEM PRIVATE ${WL_PROTOS_DIR}) -endif() -if(BUILD_WITH_XCB) - target_include_directories(comp_main SYSTEM PRIVATE ${XCB_INCLUDE_DIRS}) -endif() -if(BUILD_WITH_EGL) - target_include_directories(comp_main SYSTEM PRIVATE ${EGL_INCLUDE_DIRS}) -endif() - -add_subdirectory(shaders) diff --git a/src/xrt/targets/CMakeLists.txt b/src/xrt/targets/CMakeLists.txt index eb4a5069c..d9d2d99e7 100644 --- a/src/xrt/targets/CMakeLists.txt +++ b/src/xrt/targets/CMakeLists.txt @@ -72,7 +72,9 @@ if(BUILD_TRACKING) endif() add_subdirectory(common) -add_subdirectory(openxr) +if(BUILD_TARGET_OPENXR) + add_subdirectory(openxr) +endif() add_subdirectory(cli) if(BUILD_TARGET_GUI)