From 4b6491aa16587c89d46983c79829205b3e718f1a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 3 Mar 2023 20:42:33 +0000 Subject: [PATCH] cmake: Introduce a new module category --- CMakeLists.txt | 30 ++++++++++++------- src/xrt/CMakeLists.txt | 11 +++---- src/xrt/compositor/CMakeLists.txt | 8 ++--- .../include/xrt/xrt_config_build.h.cmake_in | 14 ++++++--- src/xrt/targets/common/CMakeLists.txt | 8 ++--- src/xrt/targets/common/target_instance.c | 8 ++--- 6 files changed, 47 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9a60a606..f0d4f9b1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,14 +242,20 @@ option_with_deps(XRT_HAVE_OPENCV "Enable OpenCV backend" DEPENDS OpenCV_FOUND) option_with_deps(XRT_HAVE_BASALT_SLAM "Enable Basalt support" DEPENDS basalt_FOUND) option_with_deps(XRT_HAVE_KIMERA_SLAM "Enable Kimera support" DEPENDS kimera_vio_FOUND) +option(XRT_MODULE_IPC "Enable the build of the IPC layer" ON) +option(XRT_MODULE_COMPOSITOR "Enable the compositor at all" ON) +option_with_deps(XRT_MODULE_COMPOSITOR_MAIN "Build main compositor host functionality" DEPENDS + XRT_MODULE_COMPOSITOR + XRT_HAVE_VULKAN + "XRT_HAVE_WAYLAND OR XRT_HAVE_XCB OR ANDROID OR WIN32" + ) +option_with_deps(XRT_MODULE_COMPOSITOR_NULL "Build testing null compositor" DEPENDS XRT_MODULE_COMPOSITOR XRT_HAVE_VULKAN) + # Feature configuration (sorted) option(XRT_FEATURE_COLOR_LOG "Enable logging in color on supported platforms" ON) -option_with_deps(XRT_FEATURE_COMPOSITOR_MAIN "Build main compositor host functionality" DEPENDS XRT_HAVE_VULKAN "XRT_HAVE_WAYLAND OR XRT_HAVE_XCB OR ANDROID OR WIN32") -option_with_deps(XRT_FEATURE_COMPOSITOR_NULL "Build testing null compositor" DEPENDS XRT_HAVE_VULKAN) -option(XRT_FEATURE_IPC "Enable the build of the IPC layer" ON) -option_with_deps(XRT_FEATURE_OPENXR "Build OpenXR runtime target" DEPENDS "XRT_FEATURE_COMPOSITOR_MAIN OR XRT_FEATURE_COMPOSITOR_NULL") +option_with_deps(XRT_FEATURE_OPENXR "Build OpenXR runtime target" DEPENDS "XRT_MODULE_COMPOSITOR_MAIN OR XRT_MODULE_COMPOSITOR_NULL") option_with_deps(XRT_FEATURE_RENDERDOC "Enable RenderDoc API" DEPENDS "RT_LIBRARY OR WIN32") -option_with_deps(XRT_FEATURE_SERVICE "Enable separate service module for OpenXR runtime" DEPENDS XRT_FEATURE_IPC XRT_FEATURE_OPENXR) +option_with_deps(XRT_FEATURE_SERVICE "Enable separate service module for OpenXR runtime" DEPENDS XRT_MODULE_IPC XRT_FEATURE_OPENXR) option_with_deps(XRT_FEATURE_SERVICE_SYSTEMD "Enable systemd socket activation of the service" DEPENDS XRT_HAVE_SYSTEMD XRT_FEATURE_SERVICE) option_with_deps(XRT_FEATURE_SLAM "Enable SLAM tracking support" DEPENDS XRT_HAVE_OPENCV "XRT_HAVE_BASALT_SLAM OR XRT_HAVE_KIMERA_SLAM") option_with_deps(XRT_FEATURE_STEAMVR_PLUGIN "Build SteamVR plugin" DEPENDS "NOT ANDROID") @@ -318,7 +324,7 @@ set(XRT_OXR_RUNTIME_SUFFIX monado CACHE STRING "OpenXR client library suffix") # cmake-format: on # Most users won't touch these. -mark_as_advanced(XRT_FEATURE_COMPOSITOR_MAIN XRT_FEATURE_COMPOSITOR_NULL XRT_FEATURE_OPENXR) +mark_as_advanced(XRT_MODULE_COMPOSITOR_MAIN XRT_MODULE_COMPOSITOR_NULL XRT_FEATURE_OPENXR) # Defaults for OpenXR layer support if(NOT DEFINED XRT_FEATURE_OPENXR_LAYER_DEPTH) @@ -502,11 +508,13 @@ message(STATUS "# XCB: ${XRT_HAVE_XCB}") message(STATUS "# XLIB: ${XRT_HAVE_XLIB}") message(STATUS "# XRANDR: ${XRT_HAVE_XRANDR}") message(STATUS "#") +message(STATUS "# MODULE_IPC ${XRT_MODULE_IPC}") +message(STATUS "# MODULE_COMPOSITOR ${XRT_MODULE_COMPOSITOR}") +message(STATUS "# MODULE_COMPOSITOR_MAIN ${XRT_MODULE_COMPOSITOR_MAIN}") +message(STATUS "# MODULE_COMPOSITOR_NULL ${XRT_MODULE_COMPOSITOR_NULL}") +message(STATUS "#") message(STATUS "# FEATURE_CLIENT_DEBUG_GUI: ${XRT_FEATURE_CLIENT_DEBUG_GUI}") message(STATUS "# FEATURE_COLOR_LOG: ${XRT_FEATURE_COLOR_LOG}") -message(STATUS "# FEATURE_COMPOSITOR_MAIN: ${XRT_FEATURE_COMPOSITOR_MAIN}") -message(STATUS "# FEATURE_COMPOSITOR_NULL: ${XRT_FEATURE_COMPOSITOR_NULL}") -message(STATUS "# FEATURE_IPC: ${XRT_FEATURE_IPC}") message(STATUS "# FEATURE_OPENXR: ${XRT_FEATURE_OPENXR}") message(STATUS "# FEATURE_OPENXR_LAYER_CUBE: ${XRT_FEATURE_OPENXR_LAYER_CUBE}") message(STATUS "# FEATURE_OPENXR_LAYER_CYLINDER: ${XRT_FEATURE_OPENXR_LAYER_CYLINDER}") @@ -549,6 +557,6 @@ message(STATUS "#####----- Config -----#####") if(XRT_FEATURE_SERVICE AND NOT XRT_FEATURE_OPENXR) message(FATAL_ERROR "XRT_FEATURE_SERVICE requires XRT_FEATURE_OPENXR to be enabled") endif() -if(XRT_FEATURE_SERVICE AND NOT XRT_FEATURE_IPC) - message(FATAL_ERROR "XRT_FEATURE_SERVICE requires XRT_FEATURE_IPC to be enabled") +if(XRT_FEATURE_SERVICE AND NOT XRT_MODULE_IPC) + message(FATAL_ERROR "XRT_FEATURE_SERVICE requires XRT_MODULE_IPC to be enabled") endif() diff --git a/src/xrt/CMakeLists.txt b/src/xrt/CMakeLists.txt index 01b8d1f29..76fdba482 100644 --- a/src/xrt/CMakeLists.txt +++ b/src/xrt/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2022, Collabora, Ltd. +# Copyright 2019-2023, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 # Order matters. @@ -6,10 +6,11 @@ add_subdirectory(include) add_subdirectory(auxiliary) add_subdirectory(tracking) add_subdirectory(drivers) -add_subdirectory(compositor) +if(XRT_MODULE_COMPOSITOR) + add_subdirectory(compositor) +endif() add_subdirectory(state_trackers) -add_subdirectory(targets) - -if(XRT_FEATURE_IPC) +if(XRT_MODULE_IPC) add_subdirectory(ipc) endif() +add_subdirectory(targets) diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt index 3a8d01062..ef51b7e13 100644 --- a/src/xrt/compositor/CMakeLists.txt +++ b/src/xrt/compositor/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2022, Collabora, Ltd. +# Copyright 2019-2023, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 ### @@ -167,7 +167,7 @@ endif() # Main library # -if(XRT_FEATURE_COMPOSITOR_MAIN) +if(XRT_MODULE_COMPOSITOR_MAIN) add_library( comp_main STATIC @@ -295,7 +295,7 @@ endif() # Null compositor # -if(XRT_FEATURE_COMPOSITOR_NULL) +if(XRT_MODULE_COMPOSITOR_NULL) add_subdirectory(null) endif() @@ -314,7 +314,7 @@ target_link_libraries( ) target_include_directories(comp_multi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -if(XRT_FEATURE_COMPOSITOR_MAIN) +if(XRT_MODULE_COMPOSITOR_MAIN) target_link_libraries(comp_main PRIVATE comp_multi) endif() diff --git a/src/xrt/include/xrt/xrt_config_build.h.cmake_in b/src/xrt/include/xrt/xrt_config_build.h.cmake_in index 38828a23b..161371a96 100644 --- a/src/xrt/include/xrt/xrt_config_build.h.cmake_in +++ b/src/xrt/include/xrt/xrt_config_build.h.cmake_in @@ -1,4 +1,4 @@ -// Copyright 2020-2022, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -9,12 +9,18 @@ #pragma once + +/* keep sorted */ + +#cmakedefine XRT_MODULE_IPC +#cmakedefine XRT_MODULE_COMPOSITOR +#cmakedefine XRT_MODULE_COMPOSITOR_MAIN +#cmakedefine XRT_MODULE_COMPOSITOR_NULL + + /* keep sorted */ #cmakedefine XRT_FEATURE_COLOR_LOG -#cmakedefine XRT_FEATURE_COMPOSITOR_MAIN -#cmakedefine XRT_FEATURE_COMPOSITOR_NULL -#cmakedefine XRT_FEATURE_IPC #cmakedefine XRT_FEATURE_OPENXR #cmakedefine XRT_FEATURE_OPENXR_DEBUG_UTILS #cmakedefine XRT_FEATURE_OPENXR_LAYER_CUBE diff --git a/src/xrt/targets/common/CMakeLists.txt b/src/xrt/targets/common/CMakeLists.txt index 6e624d8c0..b002f6b36 100644 --- a/src/xrt/targets/common/CMakeLists.txt +++ b/src/xrt/targets/common/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2022, Collabora, Ltd. +# Copyright 2019-2023, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 #### @@ -165,7 +165,7 @@ endif() # Instance # -if(XRT_FEATURE_COMPOSITOR_MAIN OR XRT_FEATURE_COMPOSITOR_NULL) +if(XRT_MODULE_COMPOSITOR_MAIN OR XRT_MODULE_COMPOSITOR_NULL) add_library(target_instance STATIC target_instance.c) target_link_libraries( target_instance @@ -178,11 +178,11 @@ if(XRT_FEATURE_COMPOSITOR_MAIN OR XRT_FEATURE_COMPOSITOR_NULL) ) target_include_directories(target_instance PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - if(XRT_FEATURE_COMPOSITOR_MAIN) + if(XRT_MODULE_COMPOSITOR_MAIN) target_link_libraries(target_instance PRIVATE comp_main) endif() - if(XRT_FEATURE_COMPOSITOR_NULL) + if(XRT_MODULE_COMPOSITOR_NULL) target_link_libraries(target_instance PRIVATE comp_null) endif() endif() diff --git a/src/xrt/targets/common/target_instance.c b/src/xrt/targets/common/target_instance.c index 73f430316..63ad6d8fc 100644 --- a/src/xrt/targets/common/target_instance.c +++ b/src/xrt/targets/common/target_instance.c @@ -15,7 +15,7 @@ #include "util/u_trace_marker.h" #include "util/u_system_helpers.h" -#ifdef XRT_FEATURE_COMPOSITOR_MAIN +#ifdef XRT_MODULE_COMPOSITOR_MAIN #include "main/comp_main_interface.h" #endif @@ -24,7 +24,7 @@ #include -#ifdef XRT_FEATURE_COMPOSITOR_MAIN +#ifdef XRT_MODULE_COMPOSITOR_MAIN #define USE_NULL_DEFAULT (false) #else #define USE_NULL_DEFAULT (true) @@ -73,7 +73,7 @@ t_instance_create_system(struct xrt_instance *xinst, bool use_null = debug_get_bool_option_use_null(); -#ifdef XRT_FEATURE_COMPOSITOR_NULL +#ifdef XRT_MODULE_COMPOSITOR_NULL if (use_null) { xret = null_compositor_create_system(head, &xsysc); } @@ -84,7 +84,7 @@ t_instance_create_system(struct xrt_instance *xinst, } #endif -#ifdef XRT_FEATURE_COMPOSITOR_MAIN +#ifdef XRT_MODULE_COMPOSITOR_MAIN if (xret == XRT_SUCCESS && xsysc == NULL) { xret = comp_main_create_system_compositor(head, NULL, &xsysc); }