xrt: Re-arrange build to avoid unnecessary includes.

Avoid unintentionally including cJSON from the source tree when using system,
etc. This adds granularity to the usage of "external" sources.
This commit is contained in:
Ryan Pavlik 2020-03-31 14:59:02 -05:00 committed by Jakob Bornecrantz
parent 47710e0532
commit 974c68dead
80 changed files with 131 additions and 95 deletions

View file

@ -1,9 +1,5 @@
# Copyright 2019-2020, Collabora, Ltd. # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
# "Link" against this interface target if your module add_subdirectory(external)
# uses the files in "external".
add_library(xrt-external-headers INTERFACE)
target_include_directories(xrt-external-headers SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/external)
add_subdirectory(xrt) add_subdirectory(xrt)

18
src/external/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,18 @@
# Copyright 2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
add_library(xrt-external-openxr INTERFACE)
target_include_directories(xrt-external-openxr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/openxr_includes)
add_library(xrt-external-glad INTERFACE)
target_include_directories(xrt-external-glad INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/glad)
if(BUILD_WITH_SYSTEM_CJSON)
add_library(xrt-external-cjson ALIAS cJSON::cJSON)
else()
add_library(xrt-external-cjson INTERFACE)
target_include_directories(xrt-external-cjson INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/cjson)
endif()
add_library(xrt-external-flexkalman INTERFACE)
target_include_directories(xrt-external-flexkalman INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/flexkalman)

View file

@ -1,7 +1,7 @@
#include "./imgui/imgui.h" #include "imgui.h"
#include "cimgui.h" #include "cimgui.h"
#include "./imgui/imgui_internal.h" #include "imgui_internal.h"
#include "imgui_impl_sdl.h" #include "imgui_impl_sdl.h"

View file

@ -1 +1,8 @@
external_include = include_directories('.') # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
openxr_include = include_directories('openxr_includes')
cjson_include = include_directories('cjson')
flexkalman_include = include_directories('flexkalman')
glad_include = include_directories('glad')
imgui_include = include_directories('imgui')

View file

@ -19,7 +19,7 @@
#pragma once #pragma once
#include <openxr_includes/openxr.h> #include "openxr.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -112,11 +112,13 @@ add_library(aux-includes INTERFACE)
target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(aux-includes INTERFACE xrt-interfaces) target_link_libraries(aux-includes INTERFACE xrt-interfaces)
# OpenGL library. if(BUILD_WITH_OPENGL)
add_library(aux_ogl STATIC ${OGL_SOURCE_FILES}) # OpenGL library.
target_link_libraries(aux_ogl PUBLIC aux-includes) add_library(aux_ogl STATIC ${OGL_SOURCE_FILES})
# for GLAD target_link_libraries(aux_ogl PUBLIC aux-includes)
target_link_libraries(aux_ogl PRIVATE xrt-external-headers) # for GLAD
target_link_libraries(aux_ogl PUBLIC xrt-external-glad)
endif()
# OS library. # OS library.
add_library(aux_os STATIC ${OS_SOURCE_FILES}) add_library(aux_os STATIC ${OS_SOURCE_FILES})
@ -141,7 +143,6 @@ target_include_directories(aux_math SYSTEM
# Util library. # Util library.
add_library(aux_util STATIC ${UTIL_SOURCE_FILES}) add_library(aux_util STATIC ${UTIL_SOURCE_FILES})
target_link_libraries(aux_util PUBLIC aux-includes) target_link_libraries(aux_util PUBLIC aux-includes)
target_link_libraries(aux_util PUBLIC xrt-external-headers)
# for u_device # for u_device
target_link_libraries(aux_util PUBLIC aux_math) target_link_libraries(aux_util PUBLIC aux_math)
if(BUILD_WITH_JPEG) if(BUILD_WITH_JPEG)
@ -151,6 +152,8 @@ endif()
if(BUILD_WITH_SYSTEM_CJSON) if(BUILD_WITH_SYSTEM_CJSON)
target_link_libraries(aux_util PUBLIC cJSON::cJSON) target_link_libraries(aux_util PUBLIC cJSON::cJSON)
target_compile_definitions(aux_util PRIVATE XRT_USE_SYSTEM_CJSON) target_compile_definitions(aux_util PRIVATE XRT_USE_SYSTEM_CJSON)
else()
target_link_libraries(aux_util PUBLIC xrt-external-cjson)
endif() endif()
# Tracking library. # Tracking library.
@ -163,7 +166,7 @@ target_include_directories(aux_tracking SYSTEM
${EIGEN3_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}
) )
# for flexkalman # for flexkalman
target_link_libraries(aux_tracking PRIVATE xrt-external-headers) target_link_libraries(aux_tracking PRIVATE xrt-external-flexkalman)
if(BUILD_TRACKING) if(BUILD_TRACKING)
target_include_directories(aux_tracking SYSTEM target_include_directories(aux_tracking SYSTEM
PRIVATE PRIVATE

View file

@ -42,7 +42,7 @@ lib_aux_util = static_library(
), ),
include_directories: [ include_directories: [
xrt_include, xrt_include,
external_include, cjson_include,
], ],
dependencies: [ dependencies: [
xrt_config_have xrt_config_have
@ -63,7 +63,7 @@ lib_aux_ogl = static_library(
), ),
include_directories: [ include_directories: [
xrt_include, xrt_include,
external_include, glad_include,
], ],
) )
@ -150,7 +150,7 @@ endif
lib_aux_tracking = static_library( lib_aux_tracking = static_library(
'aux_tracking', 'aux_tracking',
files(tracking_srcs), files(tracking_srcs),
include_directories: [xrt_include, external_include], include_directories: [xrt_include, flexkalman_include],
dependencies: tracking_deps dependencies: tracking_deps
) )
@ -168,7 +168,6 @@ lib_aux_vk = static_library(
), ),
include_directories: [ include_directories: [
xrt_include, xrt_include,
external_include,
], ],
) )

View file

@ -7,6 +7,7 @@ comp_include = include_directories('.')
# TODO: Dependency resolution and subsequent configuration could be improved # TODO: Dependency resolution and subsequent configuration could be improved
compositor_deps = [aux, shaders, vulkan, xrt_config_vulkan] compositor_deps = [aux, shaders, vulkan, xrt_config_vulkan]
compositor_includes = [xrt_include]
compositor_srcs = [ compositor_srcs = [
'client/comp_vk_client.c', 'client/comp_vk_client.c',
@ -49,6 +50,7 @@ if build_opengl
'client/comp_gles_glue.c', 'client/comp_gles_glue.c',
] ]
compositor_deps += [opengl] compositor_deps += [opengl]
compositor_includes += [glad_include]
endif endif
if build_opengl and build_xlib if build_opengl and build_xlib
@ -114,10 +116,7 @@ endif
lib_comp = static_library( lib_comp = static_library(
'comp', 'comp',
compositor_srcs, compositor_srcs,
include_directories: [ include_directories: compositor_includes,
xrt_include,
external_include,
],
dependencies: compositor_deps, dependencies: compositor_deps,
c_args: compile_args, c_args: compile_args,
cpp_args: compile_args, cpp_args: compile_args,

View file

@ -80,7 +80,7 @@ if(BUILD_DRIVER_NS)
) )
add_library(drv_ns STATIC ${NS_SOURCE_FILES}) add_library(drv_ns STATIC ${NS_SOURCE_FILES})
target_link_libraries(drv_ns PRIVATE xrt-interfaces aux_math xrt-external-headers) target_link_libraries(drv_ns PRIVATE xrt-interfaces aux_math xrt-external-cjson)
list(APPEND ENABLED_HEADSET_DRIVERS ns) list(APPEND ENABLED_HEADSET_DRIVERS ns)
endif() endif()
@ -146,7 +146,7 @@ if(BUILD_DRIVER_VIVE)
) )
add_library(drv_vive STATIC ${VIVE_SOURCE_FILES}) add_library(drv_vive STATIC ${VIVE_SOURCE_FILES})
target_link_libraries(drv_vive PRIVATE xrt-interfaces aux_os aux_util aux_math) target_link_libraries(drv_vive PRIVATE xrt-interfaces aux_os aux_util aux_math xrt-external-cjson)
target_link_libraries(drv_vive PRIVATE ${ZLIB_LIBRARIES}) target_link_libraries(drv_vive PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(drv_vive PRIVATE ${ZLIB_INCLUDE_DIRS}) target_include_directories(drv_vive PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND ENABLED_HEADSET_DRIVERS vive) list(APPEND ENABLED_HEADSET_DRIVERS vive)

View file

@ -50,7 +50,10 @@ lib_drv_ns = static_library(
'north_star/ns_interface.h', 'north_star/ns_interface.h',
'north_star/ns_prober.c', 'north_star/ns_prober.c',
), ),
include_directories: [xrt_include, external_include], include_directories: [
xrt_include,
cjson_include,
],
dependencies: [aux, xrt_config_drivers], dependencies: [aux, xrt_config_drivers],
build_by_default: 'ns' in drivers, build_by_default: 'ns' in drivers,
) )
@ -126,7 +129,10 @@ lib_drv_vive = static_library(
'vive/vive_controller_driver.c', 'vive/vive_controller_driver.c',
'vive/vive_controller_interface.h' 'vive/vive_controller_interface.h'
), ),
include_directories: [xrt_include, external_include], include_directories: [
xrt_include,
cjson_include,
],
dependencies: [aux, zlib], dependencies: [aux, zlib],
build_by_default: 'vive' in drivers, build_by_default: 'vive' in drivers,
) )

View file

@ -33,6 +33,6 @@ typedef __eglMustCastToProperFunctionPointerType (*PFNEGLGETPROCADDRESSPROC)(
#include <time.h> #include <time.h>
#endif #endif
#include "openxr_includes/openxr.h" #include "openxr/openxr.h"
#include "openxr_includes/openxr_platform.h" #include "openxr/openxr_platform.h"
#include "openxr_includes/loader_interfaces.h" #include "openxr/loader_interfaces.h"

View file

@ -1,6 +1,8 @@
# Copyright 2019, Collabora, Ltd. # Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
add_subdirectory(gui) if(BUILD_WITH_OPENGL)
add_subdirectory(gui)
endif()
add_subdirectory(oxr) add_subdirectory(oxr)
add_subdirectory(prober) add_subdirectory(prober)

View file

@ -11,21 +11,21 @@ set(GUI_SOURCE_FILES
gui_scene_debug.c gui_scene_debug.c
gui_scene_main_menu.c gui_scene_main_menu.c
gui_scene_video.c gui_scene_video.c
../../../external/imgui/cimgui.cpp ../../../external/imgui/imgui/cimgui.cpp
../../../external/imgui_monado/imgui_monado.cpp ../../../external/imgui/imgui_monado/imgui_monado.cpp
../../../external/imgui/cimgui.h ../../../external/imgui/imgui/cimgui.h
../../../external/imgui/imconfig.h ../../../external/imgui/imgui/imconfig.h
../../../external/imgui/imgui.cpp ../../../external/imgui/imgui/imgui.cpp
../../../external/imgui/imgui.h ../../../external/imgui/imgui/imgui.h
../../../external/imgui/imgui_demo.cpp ../../../external/imgui/imgui/imgui_demo.cpp
../../../external/imgui/imgui_draw.cpp ../../../external/imgui/imgui/imgui_draw.cpp
../../../external/imgui/imgui_impl_opengl3.cpp ../../../external/imgui/imgui/imgui_impl_opengl3.cpp
../../../external/imgui/imgui_impl_opengl3.h ../../../external/imgui/imgui/imgui_impl_opengl3.h
../../../external/imgui/imgui_internal.h ../../../external/imgui/imgui/imgui_internal.h
../../../external/imgui/imgui_widgets.cpp ../../../external/imgui/imgui/imgui_widgets.cpp
../../../external/imgui/imstb_rectpack.h ../../../external/imgui/imgui/imstb_rectpack.h
../../../external/imgui/imstb_textedit.h ../../../external/imgui/imgui/imstb_textedit.h
../../../external/imgui/imstb_truetype.h ../../../external/imgui/imgui/imstb_truetype.h
) )
add_library(st_gui STATIC add_library(st_gui STATIC
@ -33,24 +33,27 @@ add_library(st_gui STATIC
) )
target_link_libraries(st_gui PRIVATE target_link_libraries(st_gui PRIVATE
xrt-external-headers xrt-external-glad
aux_util aux_util
) )
target_include_directories(st_gui PUBLIC target_include_directories(st_gui PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../../external/imgui
) )
if(BUILD_WITH_SDL2) if(BUILD_WITH_SDL2)
add_library(imgui_impl_sdl STATIC add_library(imgui_impl_sdl STATIC
../../../external/imgui/cimgui_sdl.cpp ../../../external/imgui/imgui/cimgui_sdl.cpp
../../../external/imgui/imgui_impl_sdl.cpp ../../../external/imgui/imgui/imgui_impl_sdl.cpp
../../../external/imgui/imgui_impl_sdl.h ../../../external/imgui/imgui/imgui_impl_sdl.h
) )
target_link_libraries(imgui_impl_sdl PRIVATE target_link_libraries(imgui_impl_sdl PRIVATE
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
xrt-external-headers
) )
target_include_directories(imgui_impl_sdl PRIVATE target_include_directories(imgui_impl_sdl
PRIVATE
${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../../external/imgui
) )
endif() endif()

View file

@ -1,4 +1,4 @@
# Copyright 2019, Collabora, Ltd. # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
gui_sources = [ gui_sources = [
@ -11,22 +11,22 @@ gui_sources = [
'gui_scene_debug.c', 'gui_scene_debug.c',
'gui_scene_main_menu.c', 'gui_scene_main_menu.c',
'gui_scene_video.c', 'gui_scene_video.c',
'../../../external/imgui/cimgui.cpp', '../../../external/imgui/imgui/cimgui.cpp',
'../../../external/imgui/cimgui.h', '../../../external/imgui/imgui/cimgui.h',
'../../../external/imgui/imconfig.h', '../../../external/imgui/imgui/imconfig.h',
'../../../external/imgui/imgui.cpp', '../../../external/imgui/imgui/imgui.cpp',
'../../../external/imgui/imgui.h', '../../../external/imgui/imgui/imgui.h',
'../../../external/imgui/imgui_demo.cpp', '../../../external/imgui/imgui/imgui_demo.cpp',
'../../../external/imgui/imgui_draw.cpp', '../../../external/imgui/imgui/imgui_draw.cpp',
'../../../external/imgui/imgui_impl_opengl3.cpp', '../../../external/imgui/imgui/imgui_impl_opengl3.cpp',
'../../../external/imgui/imgui_impl_opengl3.h', '../../../external/imgui/imgui/imgui_impl_opengl3.h',
'../../../external/imgui/imgui_internal.h', '../../../external/imgui/imgui/imgui_internal.h',
'../../../external/imgui/imgui_widgets.cpp', '../../../external/imgui/imgui/imgui_widgets.cpp',
'../../../external/imgui/imstb_rectpack.h', '../../../external/imgui/imgui/imstb_rectpack.h',
'../../../external/imgui/imstb_textedit.h', '../../../external/imgui/imgui/imstb_textedit.h',
'../../../external/imgui/imstb_truetype.h', '../../../external/imgui/imgui/imstb_truetype.h',
'../../../external/imgui_monado/cimgui_monado.h', '../../../external/imgui/imgui_monado/cimgui_monado.h',
'../../../external/imgui_monado/imgui_monado.cpp' '../../../external/imgui/imgui_monado/imgui_monado.cpp'
] ]
gui_deps = [aux, xrt_config_have] gui_deps = [aux, xrt_config_have]
@ -36,7 +36,9 @@ lib_st_gui = static_library(
files(gui_sources), files(gui_sources),
include_directories: [ include_directories: [
xrt_include, xrt_include,
external_include, glad_include,
cjson_include,
imgui_include,
], ],
dependencies: gui_deps, dependencies: gui_deps,
) )

View file

@ -52,4 +52,4 @@ if(BUILD_WITH_EGL)
endif() endif()
add_library(st_oxr STATIC ${OXR_SOURCE_FILES}) add_library(st_oxr STATIC ${OXR_SOURCE_FILES})
target_link_libraries(st_oxr PRIVATE xrt-interfaces aux_util aux_math Vulkan::Vulkan comp_client) target_link_libraries(st_oxr PRIVATE xrt-interfaces xrt-external-openxr aux_util aux_math Vulkan::Vulkan comp_client)

View file

@ -1,4 +1,4 @@
# Copyright 2019, Collabora, Ltd. # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
compile_args = [] compile_args = []
@ -53,7 +53,7 @@ lib_st_oxr = static_library(
), ),
include_directories: [ include_directories: [
xrt_include, xrt_include,
external_include, openxr_include,
], ],
dependencies: [aux, vulkan], dependencies: [aux, vulkan],
c_args: compile_args, c_args: compile_args,

View file

@ -24,8 +24,8 @@
#include "oxr_api_verify.h" #include "oxr_api_verify.h"
#include "oxr_extension_support.h" #include "oxr_extension_support.h"
#include "openxr_includes/openxr.h" #include "openxr/openxr.h"
#include "openxr_includes/openxr_reflection.h" #include "openxr/openxr_reflection.h"
#define MAKE_EXTENSION_PROPERTIES(mixed_case, all_caps) \ #define MAKE_EXTENSION_PROPERTIES(mixed_case, all_caps) \
{XR_TYPE_EXTENSION_PROPERTIES, NULL, XR_##all_caps##_EXTENSION_NAME, \ {XR_TYPE_EXTENSION_PROPERTIES, NULL, XR_##all_caps##_EXTENSION_NAME, \

View file

@ -17,7 +17,7 @@
#include "oxr_objects.h" #include "oxr_objects.h"
#include "oxr_logger.h" #include "oxr_logger.h"
#include "openxr_includes/openxr_reflection.h" #include "openxr/openxr_reflection.h"
DEBUG_GET_ONCE_BOOL_OPTION(entrypoints, "OXR_DEBUG_ENTRYPOINTS", false) DEBUG_GET_ONCE_BOOL_OPTION(entrypoints, "OXR_DEBUG_ENTRYPOINTS", false)

View file

@ -1,4 +1,4 @@
# Copyright 2019, Collabora, Ltd. # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
prober_sources = [ prober_sources = [
@ -37,7 +37,7 @@ lib_st_prober = static_library(
include_directories: [ include_directories: [
xrt_include, xrt_include,
drv_include, drv_include,
external_include, cjson_include,
], ],
dependencies: prober_deps, dependencies: prober_deps,
) )

View file

@ -1,4 +1,4 @@
# Copyright 2019, Collabora, Ltd. # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
gui_deps = [ gui_deps = [
@ -20,9 +20,9 @@ gui = executable(
'gui_sdl2_imgui.c', 'gui_sdl2_imgui.c',
'gui_sdl2_main.c', 'gui_sdl2_main.c',
'gui_sdl2_prober.c', 'gui_sdl2_prober.c',
'../../../external/imgui/cimgui_sdl.cpp', '../../../external/imgui/imgui/cimgui_sdl.cpp',
'../../../external/imgui/imgui_impl_sdl.cpp', '../../../external/imgui/imgui/imgui_impl_sdl.cpp',
'../../../external/imgui/imgui_impl_sdl.h', '../../../external/imgui/imgui/imgui_impl_sdl.h',
), ),
link_whole: [ link_whole: [
lib_aux_os, lib_aux_os,
@ -36,10 +36,11 @@ gui = executable(
include_directories: [ include_directories: [
aux_include, aux_include,
common_include, common_include,
external_include, glad_include,
st_include, st_include,
drv_include, drv_include,
xrt_include, xrt_include,
imgui_include,
], ],
dependencies: gui_deps + driver_deps, dependencies: gui_deps + driver_deps,
) )

View file

@ -1,4 +1,4 @@
# Copyright 2019, Collabora, Ltd. # Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
###### ######
@ -17,24 +17,24 @@ runtime_target = '@0@openxr@1@'.format(runtime_prefix, runtime_suffix)
xr_api_major = 1 xr_api_major = 1
hack_deps = [] hack_deps = []
hack_src = [] hack_src = [ 'oxr_sdl2_hack.c']
hack_libs = [] hack_libs = []
hack_incs = [] hack_incs = [
glad_include,
imgui_include,
]
if sdl2.found() if sdl2.found()
hack_deps += sdl2 hack_deps += sdl2
hack_src += [ hack_src += [
'oxr_sdl2_hack.c', '../../../external/imgui/imgui/cimgui_sdl.cpp',
'../../../external/imgui/cimgui_sdl.cpp', '../../../external/imgui/imgui/imgui_impl_sdl.cpp',
'../../../external/imgui/imgui_impl_sdl.cpp', '../../../external/imgui/imgui/imgui_impl_sdl.h',
'../../../external/imgui/imgui_impl_sdl.h',
] ]
hack_libs += lib_st_gui hack_libs += lib_st_gui
hack_incs += [ hack_incs += [
st_include, st_include,
] ]
else
hack_src += 'oxr_sdl2_hack.c'
endif endif
openxr_deps = [ openxr_deps = [
@ -84,7 +84,7 @@ openxr = library(
lib_target_instance, lib_target_instance,
] + driver_libs + hack_libs, ] + driver_libs + hack_libs,
include_directories: [ include_directories: [
external_include, openxr_include,
st_include, # Sigh debian meson requires this. st_include, # Sigh debian meson requires this.
aux_include, aux_include,
common_include, common_include,