CMake Lists
CMake Lists
# CMake will look for the newest kit that isn't newer than this
# Required to find modern D3D12 header
if (MSVC)
set(CMAKE_SYSTEM_VERSION 10.0.17134.0)
endif ()
cmake_minimum_required(VERSION 3.16)
project(OpenComposite)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
# Options
# Directory for generated files, those being split headers and stubs
set(GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
# Platform-dependent flags
# Support Vulkan on Linux instead of DirectX
if (WIN32)
set(GRAPHICS_API_SUPPORT_FLAGS -DSUPPORT_DX -DSUPPORT_DX11 -DSUPPORT_DX12 -
DSUPPORT_VK -DSUPPORT_GL)
elseif (ANDROID)
set(GRAPHICS_API_SUPPORT_FLAGS -DSUPPORT_VK -DSUPPORT_GLES)
else ()
set(GRAPHICS_API_SUPPORT_FLAGS -DSUPPORT_VK -DSUPPORT_GL)
endif()
if(FORCE_COLORED_OUTPUT)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
if (WIN32)
# On Windows, use the bundled copy
target_include_directories(Vulkan INTERFACE libs/vulkan/Include) # TODO make
this private and put the public headers elsewhere
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
target_link_libraries(Vulkan INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/libs/vulkan/Lib/vulkan-1.lib)
else ()
target_link_libraries(Vulkan INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/libs/vulkan/Lib32/vulkan-1.lib)
endif ()
# We have to include the vulkan library, since the linker is now set to fail
if we use undefined symbols
# On Gentoo at least, it seems there's nothing in Vulkan_LIBRARIES
if ("${Vulkan_LIBRARIES}")
target_link_libraries(Vulkan INTERFACE ${Vulkan_LIBRARIES})
else ()
target_link_libraries(Vulkan INTERFACE -lvulkan)
endif ()
endif ()
# === OpenXR ===
if (USE_SYSTEM_OPENXR)
find_package(OpenXR)
set(XrLib OpenXR::openxr_loader)
endif()
if (NOT OpenXR_FOUND)
# Building CMake subprojects is a real pain (IMO), so just build this here
set(XrDir libs/openxr-sdk)
set(XrDirLoader libs/openxr-sdk/src/loader)
set(XrDirCommon libs/openxr-sdk/src/common)
if (ANDROID)
# Whatever consumes this library must then link to an OpenXR loader,
such as the Oculus one
add_library(OpenXR STATIC scripts/empty.c) # Doesn't do anything
else ()
add_library(OpenXR STATIC
${XrDirLoader}/api_layer_interface.cpp
${XrDirLoader}/api_layer_interface.hpp
${XrDirLoader}/loader_core.cpp
${XrDirLoader}/loader_instance.cpp
${XrDirLoader}/loader_instance.hpp
${XrDirLoader}/loader_logger.cpp
${XrDirLoader}/loader_logger.hpp
${XrDirLoader}/loader_logger_recorders.cpp
${XrDirLoader}/loader_logger_recorders.hpp
${XrDirLoader}/manifest_file.cpp
${XrDirLoader}/manifest_file.hpp
${XrDirLoader}/runtime_interface.cpp
${XrDirLoader}/runtime_interface.hpp
${XrDirLoader}/xr_generated_loader.hpp
${XrDirLoader}/xr_generated_loader.cpp
${XrDir}/src/xr_generated_dispatch_table.h
${XrDir}/src/xr_generated_dispatch_table.c
${XrDirCommon}/filesystem_utils.cpp
${XrDirCommon}/object_info.cpp
${XrDir}/src/external/jsoncpp/src/lib_json/json_reader.cpp
${XrDir}/src/external/jsoncpp/src/lib_json/json_value.cpp
${XrDir}/src/external/jsoncpp/src/lib_json/json_writer.cpp
)
endif()
target_include_directories(OpenXR PRIVATE ${XrDirCommon} ${XrDir}/src $
{XrDir}/src/external/jsoncpp/include)
target_include_directories(OpenXR PUBLIC ${XrDir}/include)
# Platform-dependent flags
if (WIN32)
target_compile_definitions(OpenXR PRIVATE -DXR_OS_WINDOWS -
DXR_USE_PLATFORM_WIN32
-DXR_USE_GRAPHICS_API_D3D11 -DXR_USE_GRAPHICS_API_D3D12 -
DXR_USE_GRAPHICS_API_OPENGL)
target_link_libraries(OpenXR PUBLIC advapi32 pathcch OpenGL32)
else()
# TODO Turtle1331 should we include -DXR_USE_PLATFORM_(XLIB|XCB|
WAYLAND) here?
target_compile_definitions(OpenXR PRIVATE -DXR_OS_LINUX
-DXR_USE_GRAPHICS_API_OPENGL -DXR_USE_GRAPHICS_API_VULKAN)
target_link_libraries(OpenXR PUBLIC -ldl)
endif()
target_link_libraries(OpenXR PUBLIC Vulkan)
if (ANDROID)
target_compile_definitions(OpenXR PUBLIC -DXR_USE_PLATFORM_ANDROID -
DXR_USE_GRAPHICS_API_OPENGL_ES)
endif()
set(XrLib OpenXR)
endif()
if (USE_SYSTEM_GLM)
find_package(glm)
set(glmLib glm::glm)
endif()
if (NOT glm_FOUND)
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE libs/glm) # No separate include
directory :(
set(glmLib glm)
endif()
DrvOpenXR/XrDriverPrivate.h
DrvOpenXR/XrBackend.cpp
DrvOpenXR/XrBackend.h
DrvOpenXR/XrTrackedDevice.cpp
DrvOpenXR/XrTrackedDevice.h
DrvOpenXR/XrHMD.cpp
DrvOpenXR/XrHMD.h
DrvOpenXR/XrController.cpp
DrvOpenXR/XrController.h
DrvOpenXR/tmp_gfx/TemporaryGraphics.cpp
DrvOpenXR/tmp_gfx/TemporaryGraphics.h
DrvOpenXR/tmp_gfx/TemporaryD3D11.cpp
DrvOpenXR/tmp_gfx/TemporaryD3D11.h
DrvOpenXR/tmp_gfx/TemporaryVk.cpp
DrvOpenXR/tmp_gfx/TemporaryVk.h
# Ensuring vrtypes.h exists should mean the rest of our generated interfaces
exists
${GENERATED_DIR}/interfaces/vrtypes.h
${GENERATED_DIR}/static_bases.gen.h
)
target_include_directories(DrvOpenXR PUBLIC DrvOpenXR/pub ${CMAKE_BINARY_DIR})
target_include_directories(DrvOpenXR PRIVATE DrvOpenXR OpenOVR)
target_link_libraries(DrvOpenXR PUBLIC OpenVR ${XrLib} ${glmLib})
target_compile_definitions(DrvOpenXR PRIVATE ${GRAPHICS_API_SUPPORT_FLAGS} -
D_CRT_SECURE_NO_WARNINGS)
source_group(Public REGULAR_EXPRESSION DrvOpenXR/pub/*)
add_library(OCCore STATIC
# This file is used to generate the precompiled headers
OpenOVR/stdafx.cpp
OpenOVR/Compositor/compositor.cpp
OpenOVR/Compositor/dx11compositor.cpp
OpenOVR/Compositor/dx10compositor.cpp
OpenOVR/Compositor/dx12compositor.cpp
OpenOVR/Compositor/glcompositor.cpp
OpenOVR/Compositor/glescompositor.cpp
OpenOVR/Compositor/vkcompositor.cpp
OpenOVR/convert.cpp
OpenOVR/logging.cpp
OpenOVR/linux_funcs.cpp
OpenOVR/Misc/Config.cpp
OpenOVR/Misc/debug_helper.cpp
OpenOVR/Misc/Haptics.cpp
OpenOVR/Misc/xrutil.cpp
OpenOVR/Misc/xrmoreutils.cpp
OpenOVR/Misc/Keyboard/KeyboardLayout.cpp
OpenOVR/Misc/Keyboard/SudoFontMeta.cpp
OpenOVR/Misc/Keyboard/VRKeyboard.cpp
OpenOVR/Misc/Input/InteractionProfile.cpp
OpenOVR/Misc/Input/OculusInteractionProfile.cpp
OpenOVR/Misc/Input/KhrSimpleInteractionProfile.cpp
OpenOVR/Misc/Input/ViveInteractionProfile.cpp
OpenOVR/Misc/Input/IndexControllerInteractionProfile.cpp
OpenOVR/Misc/Input/HolographicInteractionProfile.cpp
OpenOVR/Misc/Input/ReverbG2InteractionProfile.cpp
OpenOVR/OpenOVR.cpp
OpenOVR/Reimpl/BaseApplications.cpp
OpenOVR/Reimpl/BaseChaperone.cpp
OpenOVR/Reimpl/BaseChaperoneSetup.cpp
OpenOVR/Reimpl/BaseClientCore.cpp
OpenOVR/Reimpl/BaseCompositor.cpp
OpenOVR/Reimpl/BaseExtendedDisplay.cpp
OpenOVR/Reimpl/BaseInput.cpp
OpenOVR/Reimpl/BaseInput_Hand.cpp
OpenOVR/Reimpl/BaseInputInternal.cpp
OpenOVR/Reimpl/BaseOverlay.cpp
OpenOVR/Reimpl/BaseOverlayView.cpp
OpenOVR/Reimpl/BaseRenderModels.cpp
OpenOVR/Reimpl/BaseScreenshots.cpp
OpenOVR/Reimpl/BaseSettings.cpp
OpenOVR/Reimpl/BaseSystem.cpp
OpenOVR/Reimpl/BaseMailbox.cpp
OpenOVR/Reimpl/BaseControlPanel.cpp
OpenOVR/Reimpl/BaseHeadsetView.cpp
OpenOVR/Reimpl/CVRApplications.cpp
OpenOVR/Reimpl/CVRChaperone.cpp
OpenOVR/Reimpl/CVRChaperoneSetup.cpp
OpenOVR/Reimpl/CVRClientCore.cpp
OpenOVR/Reimpl/CVRCompositor.cpp
OpenOVR/Reimpl/CVRExtendedDisplay.cpp
OpenOVR/Reimpl/CVRInput.cpp
OpenOVR/Reimpl/CVRInputInternal.cpp
OpenOVR/Reimpl/CVROverlay.cpp
OpenOVR/Reimpl/CVROverlayView.cpp
OpenOVR/Reimpl/CVRRenderModels.cpp
OpenOVR/Reimpl/CVRScreenshots.cpp
OpenOVR/Reimpl/CVRSettings.cpp
OpenOVR/Reimpl/CVRSystem.cpp
OpenOVR/Reimpl/CVRMailbox.cpp
OpenOVR/Reimpl/CVRControlPanel.cpp
OpenOVR/Reimpl/CVRHeadsetView.cpp
${GENERATED_DIR}/stubs.gen.cpp
# Base classes
OpenOVR/Reimpl/BaseServerDriverHost.cpp OpenOVR/Reimpl/BaseServerDriverHost.h
# Definitions
OpenOVR/Reimpl/CVRServerDriverHost.cpp
# Headers
OpenOVR/BaseCommon.h
OpenOVR/Compositor/compositor.h
OpenOVR/convert.h
OpenOVR/custom_types.h
OpenOVR/logging.h
OpenOVR/Misc/Config.h
OpenOVR/Misc/debug_helper.h
OpenOVR/Misc/Haptics.h
OpenOVR/Misc/ini.h
OpenOVR/Misc/json/json-forwards.h
OpenOVR/Misc/json/json.h
OpenOVR/Misc/Keyboard/KeyboardLayout.h
OpenOVR/Misc/Keyboard/SudoFontMeta.h
OpenOVR/Misc/Keyboard/VRKeyboard.h
OpenOVR/Misc/Input/InteractionProfile.h
OpenOVR/Misc/Input/OculusInteractionProfile.h
OpenOVR/Misc/Input/KhrSimpleInteractionProfile.h
OpenOVR/Misc/lodepng.h
OpenOVR/Misc/ScopeGuard.h
OpenOVR/Reimpl/BaseApplications.h
OpenOVR/Reimpl/BaseChaperone.h
OpenOVR/Reimpl/BaseChaperoneSetup.h
OpenOVR/Reimpl/BaseClientCore.h
OpenOVR/Reimpl/BaseCompositor.h
OpenOVR/Reimpl/BaseExtendedDisplay.h
OpenOVR/Reimpl/BaseInput.h
OpenOVR/Reimpl/BaseInputInternal.cpp
OpenOVR/Reimpl/BaseOverlay.h
OpenOVR/Reimpl/BaseOverlayView.h
OpenOVR/Reimpl/BaseRenderModels.h
OpenOVR/Reimpl/BaseScreenshots.h
OpenOVR/Reimpl/BaseSettings.h
OpenOVR/Reimpl/BaseSystem.h
OpenOVR/Reimpl/BaseMailbox.h
OpenOVR/Reimpl/BaseControlPanel.h
OpenOVR/Reimpl/BaseHeadsetView.h
OpenOVR/Reimpl/Interfaces.h
${GENERATED_DIR}/static_bases.gen.h
OpenOVR/resources.h
OpenOVR/stdafx.h
OpenOVR/steamvr_abi.h
OpenOVR/targetver.h
# Newly-added classes
OpenOVR/Drivers/DriverManager.cpp
OpenOVR/Drivers/DriverManager.h
OpenOVR/Drivers/Backend.cpp
OpenOVR/Drivers/Backend.h
# While not actually part of OCCore, list all the OpenVR interfaces here so
they are easily accessable in IDE
OpenVRHeaders/custom_interfaces/IVRClientCore_002.h
OpenVRHeaders/custom_interfaces/IVRClientCore_003.h
OpenVRHeaders/custom_interfaces/IVRCompositor_017.h
OpenVRHeaders/custom_interfaces/IVRMailbox_001.h
OpenVRHeaders/custom_interfaces/IVRInputInternal_002.h
OpenVRHeaders/custom_interfaces/IVRControlPanel_006.h
# Ensuring vrtypes.h exists should mean the rest of our generated interfaces
exists
${GENERATED_DIR}/interfaces/vrtypes.h
)
target_include_directories(OCCore PUBLIC OpenOVR ${CMAKE_BINARY_DIR}) # TODO make
this private and put the public headers elsewhere
target_include_directories(OCCore PRIVATE BundledLibs OpenVRHeaders)
target_compile_definitions(OCCore PRIVATE ${GRAPHICS_API_SUPPORT_FLAGS})
# Require that all symbols are defined on Linux - this is always done on Windows
# Also on Linux, put all the static libraries in a group to avoid ordering problems
if (NOT WIN32)
target_link_libraries(OCOVR PRIVATE -Wl,--no-undefined)
target_link_libraries(OCOVR PUBLIC -Wl,--start-group OCCore DrvOpenXR -Wl,--
end-group)
else ()
# On Windows this isn't a problem since the linker knows how to figure this
stuff out
target_link_libraries(OCOVR OCCore DrvOpenXR)
endif ()
# The -Bsymbolic makes this work on exported functions - otherwise those will still
use the first-defined one.
# See the comment at the top about -fvisibility=hidden
if (WIN32)
else ()
target_link_options(OCOVR PRIVATE -Wl,-Bsymbolic -Wl,-Bsymbolic-functions)
# Ensure all required symbols are actually found, don't produce a binary that
can't be loaded
target_link_options(OCOVR PRIVATE -z defs)