Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ set(SK_BUILD_TESTS ON CACHE BOOL "Build the StereoKitCTest pro
set(SK_BUILD_SHARED_LIBS ON CACHE BOOL "Should StereoKit build as a shared, or static library?")
set(SK_DYNAMIC_OPENXR OFF CACHE BOOL "Dynamic link with the standard OpenXR Loader. Not what you want on desktop, but on Android you may need to dynamic link with other loaders.")
set(SK_WINDOWS_GL OFF CACHE BOOL "Build Windows version using OpenGL as the renderer. This is primarily for debugging GL code while developing on Windows.")
set(SK_LOCAL_SK_RENDERER OFF CACHE BOOL "Build using a local version of sk_renderer, instead of the latest release. This is useful for testing in-progress changes to sk_renderer.")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sk_renderer/CMakeLists.txt")
set(SK_DEFAULT_LOCAL_SK_RENDERER ON)
else()
set(SK_DEFAULT_LOCAL_SK_RENDERER OFF)
endif()
set(SK_LOCAL_SK_RENDERER ${SK_DEFAULT_LOCAL_SK_RENDERER} CACHE BOOL "Build using a local version of sk_renderer, instead of the latest release. This is useful for testing in-progress changes to sk_renderer.")
set(SK_LOCAL_SK_APP OFF CACHE BOOL "Build using a local version of sk_app, instead of the latest release. This is useful for testing in-progress changes to sk_app.")
set(SK_PROFILE OFF CACHE BOOL "Build with Tracy profiler enabled.")
set(SK_STRIP_DEBUG_SYMBOLS ON CACHE BOOL "Strip debug symbols from the shared library. Disable on Android to keep symbols embedded for native debugging.")
Expand Down Expand Up @@ -299,9 +304,9 @@ set(SKR_BUILD_EXAMPLES OFF CACHE PATH "Faster build" FORCE)
# If we're only using the SVSL shader compiler, we can drop glslang from
# skshaderc and save ourselves a lot of binary size and build time!
if (SK_USE_SVSL)
set(SKSHADERC_ENABLE_GLSLANG OFF CACHE BOOL "Not needed with SVSL" FORCE)
set(SKSHADERC_ENABLE_GLSLANG OFF CACHE BOOL "Not needed with SVSL")
else()
set(SKSHADERC_ENABLE_GLSLANG ON CACHE BOOL "Required for HLSL shaders" FORCE)
set(SKSHADERC_ENABLE_GLSLANG ON CACHE BOOL "Required for HLSL shaders")
endif()
if (NOT SK_LOCAL_SK_RENDERER)
CPMAddPackage(
Expand All @@ -312,7 +317,7 @@ if (NOT SK_LOCAL_SK_RENDERER)
else()
# For building directly with in-progress sk_renderer changes, point this to your
# local sk_renderer clone, and use it instead of CPM.
add_subdirectory(../sk_renderer ../sk_renderer/build)
add_subdirectory(../sk_renderer ${CMAKE_BINARY_DIR}/sk_renderer-local)
endif()
set_target_properties(sk_renderer PROPERTIES POSITION_INDEPENDENT_CODE ON)
# Enable Win32 Vulkan surface support for Windows builds (needed by volk)
Expand Down Expand Up @@ -709,11 +714,6 @@ if (NOT MSVC)
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_DIR:StereoKitC>/$<TARGET_FILE_PREFIX:StereoKitC>$<TARGET_FILE_BASE_NAME:StereoKitC>${SK_BIN_DEBUG_EXT} $<TARGET_FILE:StereoKitC>
)
endif()
if (SK_DYNAMIC_OPENXR AND SK_STRIP_DEBUG_SYMBOLS)
add_custom_command(TARGET StereoKitC POST_BUILD
COMMAND ${CMAKE_STRIP} --strip-debug $<TARGET_FILE:openxr_loader>
)
endif()
endif()
else()
set(SK_BIN_DEBUG_EXT ".pdb")
Expand Down Expand Up @@ -870,9 +870,15 @@ if(SK_DISTRIBUTE)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE_DIR:StereoKitC>/$<TARGET_FILE_PREFIX:StereoKitC>$<TARGET_FILE_BASE_NAME:StereoKitC>${SK_BIN_DEBUG_EXT}" "${CMAKE_CURRENT_SOURCE_DIR}/${SK_DISTRIBUTE_FOLDER}/bin/${SK_BIN_OS}/${SK_ARCH}/$<CONFIG>/$<TARGET_FILE_PREFIX:StereoKitC>$<TARGET_FILE_BASE_NAME:StereoKitC>${SK_BIN_DEBUG_EXT}" )
endif()
if (SK_DYNAMIC_OPENXR)
set(SK_OPENXR_LOADER_DIST_SRC "$<TARGET_FILE:openxr_loader>")
if (SK_STRIP_DEBUG_SYMBOLS AND NOT MSVC AND NOT APPLE)
set(SK_OPENXR_LOADER_DIST_SRC "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:openxr_loader>.stripped")
add_custom_command(TARGET StereoKitC POST_BUILD
COMMAND ${CMAKE_STRIP} --strip-debug -o "${SK_OPENXR_LOADER_DIST_SRC}" "$<TARGET_FILE:openxr_loader>" )
endif()
add_custom_command(TARGET StereoKitC POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/${SK_DISTRIBUTE_FOLDER}/bin/${SK_BIN_OS}/${SK_ARCH}/$<CONFIG>/standard"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:openxr_loader>" "${CMAKE_CURRENT_SOURCE_DIR}/${SK_DISTRIBUTE_FOLDER}/bin/${SK_BIN_OS}/${SK_ARCH}/$<CONFIG>/standard/$<TARGET_FILE_NAME:openxr_loader>" )
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SK_OPENXR_LOADER_DIST_SRC}" "${CMAKE_CURRENT_SOURCE_DIR}/${SK_DISTRIBUTE_FOLDER}/bin/${SK_BIN_OS}/${SK_ARCH}/$<CONFIG>/standard/$<TARGET_FILE_NAME:openxr_loader>" )
endif()
# Copy sk_app.jar on Android (Java classes for file dialogs, activity results)
if (ANDROID AND TARGET sk_app_jar)
Expand Down
15 changes: 15 additions & 0 deletions StereoKit/BuildStereoKitNative.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Target Name="StereoKit_BuildNative">
<Message Condition="!Exists('$(SKSDKCacheFile)')" Importance="high" Text="[StereoKit SDK] Configuring StereoKitC"/>
<Exec Condition="!Exists('$(SKSDKCacheFile)')" WorkingDirectory="$(SKSDKFolder)" Command="cmake --preset $(SKSDKPreset) -DSK_BUILD_TESTS=OFF $(SKConfigureArgs)" />
<Exec WorkingDirectory="$(SKSDKFolder)" Command="cmake --build --preset $(SKSDKPreset)" />
</Target>

<Target Name="StereoKit_CleanNative" Condition="Exists('$(SKSDKIntermediateDir)')">
<Message Importance="high" Text="[StereoKit SDK] Removing $(SKSDKIntermediateDir)"/>
<Exec Command="cmake -E rm -rf &quot;$(SKSDKIntermediateDir)&quot;" />
</Target>
</Project>
27 changes: 16 additions & 11 deletions StereoKit/BuildStereoKitSDK.targets
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,20 @@
</ItemGroup>
<!-- This needs to be a Target instead of a PreBuildEvent, otherwise it won't
run unless the consuming project has dirty code.-->
<Target Name="StereoKit_BuildNative" BeforeTargets="BeforeBuild;StereoKit_Properties">
<Target Name="StereoKit_BuildNative" BeforeTargets="BeforeBuild;StereoKit_Properties" Condition="'$(DesignTimeBuild)' != 'true'">
<PropertyGroup>
<SKSDKPresetFast Condition="'$(Configuration)'=='Debug'">_Fast</SKSDKPresetFast>
<!-- Overridable, so a cross-compile can pick a preset that doesn't follow the OS name, like MinGW. -->
<SKSDKPreset Condition="'$(SKSDKPreset)'==''">$(SKSDKBuildOS)_$(SKSDKBuildModePreset)_$(Configuration)$(SKSDKPresetFast)</SKSDKPreset>
<!-- Windows uses multi-config generator (MSVC), others use single-config (Ninja) -->
<SKSDKCacheFile Condition="'$(SKSDKBuildOS)'=='Win32'">$(SKSDKFolder)\bin\intermediate\$(SKSDKBuildOS)_$(SKSDKBuildModePreset)$(SKSDKPresetFast)\CMakeCache.txt</SKSDKCacheFile>
<SKSDKCacheFile Condition="'$(SKSDKCacheFile)'==''" >$(SKSDKFolder)\bin\intermediate\$(SKSDKBuildOS)_$(SKSDKBuildModePreset)_$(Configuration)$(SKSDKPresetFast)\CMakeCache.txt</SKSDKCacheFile>

<SKBuildCommand >cd "$(SKSDKFolder)"</SKBuildCommand>
<SKBuildCommand Condition="!Exists('$(SKSDKCacheFile)')">$(SKBuildCommand) &amp;&amp; cmake --preset $(SKSDKPreset) -DSK_BUILD_TESTS=OFF $(SKConfigureArgs)</SKBuildCommand>
<SKBuildCommand >$(SKBuildCommand) &amp;&amp; cmake --build --preset $(SKSDKPreset)</SKBuildCommand>
</PropertyGroup>

<Message Condition="!Exists('$(SKSDKCacheFile)')" Importance="high" Text="[StereoKit SDK] Configuring StereoKitC"/>
<Exec Command="$(SKBuildCommand)" />
<MSBuild Projects="$(MSBuildThisFileDirectory)BuildStereoKitNative.proj"
Targets="StereoKit_BuildNative"
Properties="SKSDKFolder=$(SKSDKFolder);SKSDKPreset=$(SKSDKPreset);SKSDKCacheFile=$(SKSDKCacheFile);SKConfigureArgs=$(SKConfigureArgs)"
RemoveProperties="TargetFramework;RuntimeIdentifier;Platform;Configuration;DesignTimeBuild" />
</Target>

<!-- Attach the native library binaries. -->
Expand Down Expand Up @@ -120,14 +118,21 @@

<!-- Full rebuilds of this project should also be full rebuilds of StereoKit. -->
<Target Name="SKSDKRebuild" AfterTargets="Clean">
<!-- Windows uses multi-config generator (MSVC), others use single-config (Ninja) -->
<RemoveDir Condition="'$(SKSDKBuildOS)'=='Win32'" Directories="$(SKSDKFolder)\bin\intermediate\$(SKSDKBuildOS)_$(SKSDKBuildMode)" />
<RemoveDir Condition="'$(SKSDKBuildOS)'!='Win32'" Directories="$(SKSDKFolder)\bin\intermediate\$(SKSDKBuildOS)_$(SKSDKBuildMode)_$(Configuration)" />
<PropertyGroup>
<SKSDKPresetFast Condition="'$(Configuration)'=='Debug'">_Fast</SKSDKPresetFast>
<!-- Windows uses multi-config generator (MSVC), others use single-config (Ninja) -->
<SKSDKIntermediateDir Condition="'$(SKSDKBuildOS)'=='Win32'">$(SKSDKFolder)\bin\intermediate\$(SKSDKBuildOS)_$(SKSDKBuildModePreset)$(SKSDKPresetFast)</SKSDKIntermediateDir>
<SKSDKIntermediateDir Condition="'$(SKSDKIntermediateDir)'==''" >$(SKSDKFolder)\bin\intermediate\$(SKSDKBuildOS)_$(SKSDKBuildModePreset)_$(Configuration)$(SKSDKPresetFast)</SKSDKIntermediateDir>
</PropertyGroup>
<MSBuild Projects="$(MSBuildThisFileDirectory)BuildStereoKitNative.proj"
Targets="StereoKit_CleanNative"
Properties="SKSDKIntermediateDir=$(SKSDKIntermediateDir)"
RemoveProperties="TargetFramework;RuntimeIdentifier;Platform;Configuration;DesignTimeBuild" />
</Target>

<!-- Error out if StereoKitC hasn't successfully built! -->
<Target Name="SKSDKCheckBuildFiles" AfterTargets="PreBuildEvent" BeforeTargets="CoreCompile">
<Error Condition="!Exists('$(SKSDKLibPath)')" Text="[StereoKit SDK] StereoKitC was not properly built! Binary file $(SKSDKLibPath) is missing." />
<Message Importance="high" Text="[StereoKit SDK] Using locally built StereoKitC at $(SKSDKLibPath)"/>
</Target>
</Project>
</Project>
Loading