Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
maluoi committed Jun 6, 2022
2 parents 94827bc + 27c55cf commit 39ed436
Show file tree
Hide file tree
Showing 470 changed files with 54,840 additions and 84,294 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
StereoKitC/libraries/* linguist-vendored
StereoKitC/lib/** linguist-vendored
Tools/** -linguist-detectable
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,10 @@ ASALocalRun/
!StereoKitC/lib/bin/**
!**/Assets/**

# Ignore OpenXR related stuff
# Ignore dependency build related stuff
Tools/oxr_current.txt
StereoKitC/lib/bin/**/openxr_loader.lib
StereoKitC/lib/bin/**/*reactphysics3d.*

# Ignore cached shader blobs
*/Assets/cache
Expand All @@ -355,3 +356,6 @@ build_*/

# Xmake cache files
.xmake/

# Clangd cache
.clangd/
23 changes: 16 additions & 7 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ The test project is pretty spiffy, and it can be nice to see it in action! There
StereoKit is a cross-platform library, but many features are not platform specific! If you don't need to test on a platform other than Windows, then you only need some of the dependencies.

**Requisites:**
- Visual Studio 2019 (2022 may also work)
- VS Workload: Universal Windows Platform
- VS Workload: Desktop development with C++
- VS Workload: Game development with C++
- Visual Studio 2022
- VS Workload: Universal Windows Platform
- VS Workload: Desktop development with C++
- VS Workload: Game development with C++
- [CMake](https://cmake.org) (To build OpenXR & dependencies)

Open StereoKit.sln and _unload_ these projects
- StereoKitTest_Android
Expand All @@ -37,10 +38,18 @@ StereoKit builds Linux code using xmake running on Windows Subsystems for Linux.
It may help to build just the C++ side on Linux first to find which packages need to be installed. Here's how you build StereoKit using xmake:

```
# From StereoKit's root directory on Linux
# StereoKit uses xmake, check their docs (https://xmake.io/#/getting_started)
# for details, but here's the quick way to install:
bash <(curl -fsSL https://xmake.io/shget.text)
# here's a few other pre-reqs, mostly pulled from OpenXR's build list:
sudo apt-get update
sudo apt-get install build-essential cmake unzip libfontconfig1-dev libgl1-mesa-dev libvulkan-dev libx11-xcb-dev libxcb-dri2-0-dev libxcb-glx0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev mesa-common-dev
### From StereoKit's root directory ###
# Configure the xmake build
xmake f -p linux -a x64 --tests=y
xmake f -p linux -a x64 --tests=y -y
# Build
xmake
Expand All @@ -53,4 +62,4 @@ xmake run

## I want to build the whole NuGet package

The NuGet package build pipeline requires all the setup steps from above first! After that, you just need to run the [build powershell script](https://github.com/maluoi/StereoKit/blob/master/Build-Nuget.ps1). This script will build all binary variants, run tests, and track some statistics.
The NuGet package build pipeline requires all the setup steps from above first! After that, you just need to run the [build powershell script](https://github.com/maluoi/StereoKit/blob/master/Build-Nuget.ps1). This script will build all binary variants, run tests, and track some statistics.
98 changes: 68 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(StereoKit VERSION "0.3.5" LANGUAGES CXX C)
project(StereoKit VERSION "0.3.6" LANGUAGES CXX C)

# Default build configuration to RelWithDebInfo
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
Expand All @@ -39,6 +39,19 @@ set(SK_LINUX_EGL OFF CACHE BOOL "Force using EGL graphics bac
set(SK_MULTITHREAD_BUILD_BY_DEFAULT ON CACHE BOOL "MSVC only, on by default. This forces projects here to build with multi-threading (/MP)")
set(SK_BUILD_TESTS ON CACHE BOOL "Build the StereoKitCTest project in addition to the StereoKitC library.")
set(SK_BUILD_SHARED_LIBS ON CACHE BOOL "Should StereoKit build as a shared, or static library?")
set(SK_PHYSICS ON CACHE BOOL "Enable physics.")
set(FORCE_COLORED_OUTPUT OFF CACHE BOOL "Always produce ANSI-colored output (GNU/Clang only).")

###########################################
## Pretty colors ##
###########################################
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()

###########################################
## Dependencies ##
Expand All @@ -55,32 +68,38 @@ if (UNIX)
endif()

#### ReactPhysics3D - https://www.reactphysics3d.com/ ####
CPMAddPackage(
NAME reactphysics3d
GITHUB_REPOSITORY DanielChappuis/reactphysics3d
GIT_TAG bdc3153f552f6665ea9d2d13afd20ea871119e17 # v0.8.0
EXCLUDE_FROM_ALL YES
)
# Something in reactphysics3d seems to require -fPIC
set_property(TARGET reactphysics3d PROPERTY POSITION_INDEPENDENT_CODE ON)
# Disable warnings for reactphysics3d, it's a little horrifying
target_compile_options(reactphysics3d PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W0>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-w> )
if(SK_PHYSICS)
CPMAddPackage(
NAME reactphysics3d
GITHUB_REPOSITORY DanielChappuis/reactphysics3d
GIT_TAG 4bbbaa7c6e92942734eec696e23a2fad1f1cb8a1 # v0.9.0
EXCLUDE_FROM_ALL YES
)
# Something in reactphysics3d seems to require -fPIC
set_property(TARGET reactphysics3d PROPERTY POSITION_INDEPENDENT_CODE ON)
# Disable warnings for reactphysics3d, it's a little horrifying
target_compile_options(reactphysics3d PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W0>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-w> )

set(PHYSICS_LIB
reactphysics3d)
endif()

#### OpenXR - https://www.khronos.org/openxr/ ####
CPMAddPackage(
NAME OpenXR
VERSION 1.0.17
VERSION 1.0.22
GITHUB_REPOSITORY KhronosGroup/OpenXR-SDK
GIT_TAG bf21ccb1007bb531b45d9978919a56ea5059c245 # v1.0.17
GIT_TAG 458984d7f59d1ae6dc1b597d94b02e4f7132eaba # v1.0.22
)

###########################################
## Shader Compiler ##
###########################################

set(SK_SRC_SHADERS_HLSL
StereoKitC/shaders_builtin/shader_builtin_blit.hlsl
StereoKitC/shaders_builtin/shader_builtin_default.hlsl
StereoKitC/shaders_builtin/shader_builtin_equirect.hlsl
StereoKitC/shaders_builtin/shader_builtin_font.hlsl
Expand All @@ -104,7 +123,7 @@ foreach(SHADER ${SK_SRC_SHADERS_HLSL})
if (WIN32)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${SHADER}.h
COMMAND ${SK_SHADER_COMPILER} -h -t xge -i ${CMAKE_SOURCE_DIR}/Tools/include -o ${CMAKE_SOURCE_DIR}/StereoKitC/shaders_builtin ${CMAKE_SOURCE_DIR}/${SHADER}
COMMAND ${SK_SHADER_COMPILER} -h -t xge -i ${CMAKE_SOURCE_DIR}/Tools/include -o ${CMAKE_SOURCE_DIR}/StereoKitC/shaders_builtin/ ${CMAKE_SOURCE_DIR}/${SHADER}
DEPENDS ${SHADER} )
endif()
list(APPEND SK_SRC_SHADERS_H ${SHADER}.h)
Expand Down Expand Up @@ -141,17 +160,24 @@ elseif(WIN32)
WindowsApp) # Required for ISAC spatial audio code
endif()

if(NOT SK_PHYSICS)
message("-- Building without physics!")
add_definitions("-DSK_PHYSICS_PASSTHROUGH")
else()
message("-- Building with physics!")
endif()

###########################################
## StereoKitC ##
###########################################

set(SK_SRC_CODE
StereoKitC/stereokit.h
StereoKitC/stereokit_ui.h

StereoKitC/_stereokit.h
StereoKitC/_stereokit_ui.h
StereoKitC/color.cpp
StereoKitC/backend.cpp
StereoKitC/hierarchy.h
StereoKitC/hierarchy.cpp
StereoKitC/intersect.cpp
Expand All @@ -160,13 +186,13 @@ set(SK_SRC_CODE
StereoKitC/rect_atlas.h
StereoKitC/rect_atlas.cpp
StereoKitC/sk_math.h
StereoKitC/sk_math_dx.h
StereoKitC/sk_math.cpp
StereoKitC/sk_memory.h
StereoKitC/sk_memory.cpp
StereoKitC/spherical_harmonics.h
StereoKitC/spherical_harmonics.cpp
StereoKitC/stereokit.cpp
StereoKitC/stereokit_ui.cpp )
StereoKitC/stereokit.cpp )

set(SK_SRC_ASSET_TYPES
StereoKitC/asset_types/assets.h
Expand Down Expand Up @@ -198,6 +224,7 @@ set(SK_SRC_LIBRARIES
StereoKitC/libraries/aileron_font_data.h
StereoKitC/libraries/array.h
StereoKitC/libraries/cgltf.h
StereoKitC/libraries/cgltf.cpp
StereoKitC/libraries/ferr_hash.h
StereoKitC/libraries/ferr_hash.cpp
StereoKitC/libraries/isac_spatial_sound.h
Expand Down Expand Up @@ -235,8 +262,6 @@ set(SK_SRC_SYSTEMS
StereoKitC/systems/physics.cpp
StereoKitC/systems/render.h
StereoKitC/systems/render.cpp
StereoKitC/systems/render_sort.h
StereoKitC/systems/render_sort.cpp
StereoKitC/systems/sprite_drawer.h
StereoKitC/systems/sprite_drawer.cpp
StereoKitC/systems/system.h
Expand Down Expand Up @@ -291,6 +316,10 @@ set(SK_SRC_TOOLS
StereoKitC/tools/file_picker.h
StereoKitC/tools/file_picker.cpp )

set(SK_SRC_UI
StereoKitC/stereokit_ui.h
StereoKitC/ui/stereokit_ui.cpp )

# Switch between a static or shared library based on
# the cmake options provided.
if (SK_BUILD_SHARED_LIBS)
Expand All @@ -307,6 +336,7 @@ add_library(StereoKitC ${LIBRARY_TYPE}
${SK_SRC_HANDS}
${SK_SRC_PLATFORM}
${SK_SRC_TOOLS}
${SK_SRC_UI}
${SK_SRC_SHADERS_H} )

# Set up Visual Studio folders/filters for a more organized
Expand All @@ -318,6 +348,7 @@ source_group("systems" FILES ${SK_SRC_SYSTEMS})
source_group("hands" FILES ${SK_SRC_HANDS})
source_group("platform" FILES ${SK_SRC_PLATFORM})
source_group("tools" FILES ${SK_SRC_TOOLS})
source_group("ui" FILES ${SK_SRC_UI})

if (UNIX)
# DirectXMath on Linux needs a few extra files
Expand All @@ -336,8 +367,7 @@ target_include_directories(StereoKitC

target_link_libraries( StereoKitC
PRIVATE
reactphysics3d
PUBLIC
${PHYSICS_LIB}
openxr_loader
${LINUX_LIBS}
${WINDOWS_LIBS}
Expand All @@ -351,10 +381,14 @@ target_link_libraries( StereoKitC
if (SK_BUILD_TESTS)
add_executable( StereoKitCTest
Examples/StereoKitCTest/main.cpp
Examples/StereoKitCTest/demo_envmap.h
Examples/StereoKitCTest/demo_envmap.cpp
Examples/StereoKitCTest/demo_draw.h
Examples/StereoKitCTest/demo_draw.cpp
Examples/StereoKitCTest/demo_basics.h
Examples/StereoKitCTest/demo_basics.cpp
Examples/StereoKitCTest/demo_desktop.h
Examples/StereoKitCTest/demo_desktop.cpp
Examples/StereoKitCTest/demo_picker.h
Examples/StereoKitCTest/demo_picker.cpp
Examples/StereoKitCTest/demo_mic.h
Expand All @@ -365,8 +399,12 @@ if (SK_BUILD_TESTS)
Examples/StereoKitCTest/scene.cpp
Examples/StereoKitCTest/demo_ui.h
Examples/StereoKitCTest/demo_ui.cpp
Examples/StereoKitCTest/demo_ui_layout.h
Examples/StereoKitCTest/demo_ui_layout.cpp
Examples/StereoKitCTest/demo_world.h
Examples/StereoKitCTest/demo_world.cpp
Examples/StereoKitCTest/demo_windows.h
Examples/StereoKitCTest/demo_windows.cpp
Examples/StereoKitCTest/demo_lines.h
Examples/StereoKitCTest/demo_lines.cpp
Examples/StereoKitCTest/demo_lighting.h
Expand Down Expand Up @@ -394,7 +432,10 @@ endif()
# default, this is mostly for when using Visual Studio as
# the IDE. CLI users can pass in command line arguments.
if (MSVC AND SK_MULTITHREAD_BUILD_BY_DEFAULT)
target_compile_options(reactphysics3d PRIVATE "/MP")
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
if(SK_PHYSICS)
target_compile_options(reactphysics3d PRIVATE "/MP")
endif()
target_compile_options(openxr_loader PRIVATE "/MP")
target_compile_options(StereoKitC PRIVATE "/MP")
endif()
Expand All @@ -409,18 +450,15 @@ endif()
install(
TARGETS StereoKitC
EXPORT StereoKitC-targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

install(
FILES "StereoKitC/stereokit.h" "StereoKitC/stereokit_ui.h" "Tools/include/stereokit.hlsli"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
DESTINATION include)

install(
PROGRAMS "Tools/skshaderc"
DESTINATION ${CMAKE_INSTALL_BINDIR})
FILES "Tools/skshaderc"
DESTINATION bin)

install(
EXPORT StereoKitC-targets
Expand Down

0 comments on commit 39ed436

Please sign in to comment.