Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CMakeList feature set and hide nvn impls to users #32

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
340 changes: 204 additions & 136 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,164 @@
cmake_minimum_required(VERSION 3.15)

project(NintendoSDK CXX ASM)

set(SDK_TARGET_PLATFORM "NVN" CACHE STRING "Set build type")
set_property(CACHE SDK_TARGET_PLATFORM PROPERTY STRINGS "NVN")
set(SDK_${SDK_TARGET_PLATFORM} true)

set(NN_API "C" CACHE STRING "Set build type")
set_property(CACHE NN_API PROPERTY STRINGS "CPP" "C")

option(NN_USE_GFX "Build and statically link nn::gfx" ON)

set(NN_SOURCES "")

if(NN_USE_GFX)
if(NN_API STREQUAL "C")
unset(NN_API)
endif()

set(NN_GFX_SOURCES
include/nn/gfx/detail/gfx_DataContainer.h
include/nn/gfx/detail/gfx_Fwd.h
include/nn/gfx/detail/gfx_Misc.h
include/nn/gfx/detail/gfx_RequiredMemory.h
include/nn/gfx/detail/gfx_ResShaderImpl.h
include/nn/gfx/detail/gfx_RootSignature-api.common.h
include/nn/gfx/util/gfx_PrimitiveShape.h

include/nn/gfx/gfx_Buffer.h
include/nn/gfx/gfx_BufferInfo.h
include/nn/gfx/gfx_BufferInfoData.h
include/nn/gfx/gfx_CommandBuffer.h
include/nn/gfx/gfx_CommandBufferInfo.h
include/nn/gfx/gfx_CommandBufferInfoData.h
include/nn/gfx/gfx_Common.h
include/nn/gfx/gfx_DescriptorPool.h
include/nn/gfx/gfx_DescriptorPoolInfo.h
include/nn/gfx/gfx_DescriptorPoolInfoData.h
include/nn/gfx/gfx_DescriptorSlot.h
include/nn/gfx/gfx_Device.h
include/nn/gfx/gfx_DeviceInfo.h
include/nn/gfx/gfx_DeviceInfoData.h
include/nn/gfx/gfx_Enum.h
include/nn/gfx/gfx_GpuAddress.h
include/nn/gfx/gfx_MemoryPool.h
include/nn/gfx/gfx_MemoryPoolInfo.h
include/nn/gfx/gfx_MemoryPoolInfoData.h
include/nn/gfx/gfx_Queue.h
include/nn/gfx/gfx_QueueInfo.h
include/nn/gfx/gfx_QueueInfoData.h
include/nn/gfx/gfx_ResShader.h
include/nn/gfx/gfx_ResShaderData.h
include/nn/gfx/gfx_ResTexture.h
include/nn/gfx/gfx_ResTextureData.h
include/nn/gfx/gfx_ResUserData.h
include/nn/gfx/gfx_ResUserDataData.h
include/nn/gfx/gfx_RootSignatureData-api.common.h
include/nn/gfx/gfx_RootSignatureInfo.h
include/nn/gfx/gfx_RootSignatureInfoData.h
include/nn/gfx/gfx_Sampler.h
include/nn/gfx/gfx_SamplerInfo.h
include/nn/gfx/gfx_SamplerInfoData.h
include/nn/gfx/gfx_Shader.h
include/nn/gfx/gfx_ShaderInfo.h
include/nn/gfx/gfx_ShaderInfoData.h
include/nn/gfx/gfx_State.h
include/nn/gfx/gfx_StateInfo.h
include/nn/gfx/gfx_StateInfoData.h
include/nn/gfx/gfx_SwapChain.h
include/nn/gfx/gfx_SwapChainInfo.h
include/nn/gfx/gfx_SwapChainInfoData.h
include/nn/gfx/gfx_Sync.h
include/nn/gfx/gfx_SyncInfo.h
include/nn/gfx/gfx_SyncInfoData.h
include/nn/gfx/gfx_Texture.h
include/nn/gfx/gfx_TextureInfo.h
include/nn/gfx/gfx_TextureInfoData.h
include/nn/gfx/gfx_Types.h
include/nn/gfx/gfx_VariationBase.h

src/NintendoSDK/gfx/detail/gfx_CommonHelper.cpp
src/NintendoSDK/gfx/detail/gfx_CommonHelper.h
src/NintendoSDK/gfx/detail/gfx_GlslcFunction.cpp
src/NintendoSDK/gfx/detail/gfx_NvnHelper-os.horizon.cpp
src/NintendoSDK/gfx/detail/gfx_NvnHelper.cpp
src/NintendoSDK/gfx/detail/gfx_NvnHelper.h
src/NintendoSDK/gfx/util/gfx_PrimitiveShape.cpp

src/NintendoSDK/gfx/gfx_BufferInfo.cpp
src/NintendoSDK/gfx/gfx_CommandBufferInfo.cpp
src/NintendoSDK/gfx/gfx_DescriptorPoolInfo.cpp
src/NintendoSDK/gfx/gfx_DeviceInfo.cpp
src/NintendoSDK/gfx/gfx_MemoryPoolInfo.cpp
src/NintendoSDK/gfx/gfx_QueueInfo.cpp
src/NintendoSDK/gfx/gfx_ResShader.cpp
src/NintendoSDK/gfx/gfx_ResTexture.cpp
src/NintendoSDK/gfx/gfx_SamplerInfo.cpp
src/NintendoSDK/gfx/gfx_ShaderInfo.cpp
src/NintendoSDK/gfx/gfx_StateInfo.cpp
src/NintendoSDK/gfx/gfx_SwapChainInfo.cpp
src/NintendoSDK/gfx/gfx_SyncInfo.cpp
src/NintendoSDK/gfx/gfx_TextureInfo.cpp
)

if(SDK_NVN)
list(APPEND NN_GFX_SOURCES
include/nn/gfx/detail/gfx_Buffer-api.nvn.8.h
include/nn/gfx/detail/gfx_CommandBuffer-api.nvn.8.h
include/nn/gfx/detail/gfx_Common-api.nvn.h
include/nn/gfx/detail/gfx_DescriptorPool-api.nvn.8.h
include/nn/gfx/detail/gfx_Device-api.nvn.8.h
include/nn/gfx/detail/gfx_MemoryPool-api.nvn.8.h
include/nn/gfx/detail/gfx_Pipeline-api.nvn.8.h
include/nn/gfx/detail/gfx_Queue-api.nvn.8.h
include/nn/gfx/detail/gfx_RootSignature-api.nvn.8.h
include/nn/gfx/detail/gfx_Sampler-api.nvn.8.h
include/nn/gfx/detail/gfx_Shader-api.nvn.8.h
include/nn/gfx/detail/gfx_State-api.nvn.8.h
include/nn/gfx/detail/gfx_SwapChain-api.nvn.8.h
include/nn/gfx/detail/gfx_Sync-api.nvn.8.h
include/nn/gfx/detail/gfx_Texture-api.nvn.8.h

include/nn/gfx/gfx_BufferData-api.nvn.8.h
include/nn/gfx/gfx_CommandBufferData-api.nvn.8.h
include/nn/gfx/gfx_DescriptorPoolData-api.nvn.8.h
include/nn/gfx/gfx_DeviceData-api.nvn.8.h
include/nn/gfx/gfx_Interoperation-api.nvn.8.h
include/nn/gfx/gfx_MemoryPoolData-api.nvn.8.h
include/nn/gfx/gfx_PipelineData-api.nvn.8.h
include/nn/gfx/gfx_QueueData-api.nvn.8.h
include/nn/gfx/gfx_ResShaderData-api.nvn.h
include/nn/gfx/gfx_SamplerData-api.nvn.8.h
include/nn/gfx/gfx_ShaderData-api.nvn.8.h
include/nn/gfx/gfx_StateData-api.nvn.8.h
include/nn/gfx/gfx_SwapChainData-api.nvn.8.h
include/nn/gfx/gfx_SyncData-api.nvn.8.h
include/nn/gfx/gfx_TextureData-api.nvn.8.h

src/NintendoSDK/gfx/detail/gfx_Buffer-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_CommandBuffer-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_DescriptorPool-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Device-api.nvn.8-os.horizon.cpp
src/NintendoSDK/gfx/detail/gfx_MemoryPool-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_ResShader-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Sampler-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Shader-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_State-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Texture-api.nvn.8.cpp

src/NintendoSDK/gfx/util/gfx_ObjectDebugLabel-api.nvn.8.cpp
src/NintendoSDK/gfx/gfx_Interoperation-api.nvn.cpp
)
endif()

list(APPEND NN_SOURCES ${NN_GFX_SOURCES})
endif()

add_library(NintendoSDK OBJECT
include/nvn/nvn_FuncPtrBase.h
include/nvn/nvn_FuncPtrImpl.h
include/nvn/nvn_FuncPtrInline.h
include/nvn/nvn.h
${NN_SOURCES}

include/nn/types.h
include/nn/fs.h
include/nn/os.h
Expand Down Expand Up @@ -84,94 +238,6 @@ add_library(NintendoSDK OBJECT
include/nn/init.h
include/nn/crypto.h
include/nn/ssl.h
include/nn/gfx/detail/gfx_Buffer-api.nvn.8.h
include/nn/gfx/detail/gfx_CommandBuffer-api.nvn.8.h
include/nn/gfx/detail/gfx_Common-api.nvn.h
include/nn/gfx/detail/gfx_DataContainer.h
include/nn/gfx/detail/gfx_DescriptorPool-api.nvn.8.h
include/nn/gfx/detail/gfx_Device-api.nvn.8.h
include/nn/gfx/detail/gfx_Fwd.h
include/nn/gfx/detail/gfx_MemoryPool-api.nvn.8.h
include/nn/gfx/detail/gfx_Misc.h
include/nn/gfx/detail/gfx_Pipeline-api.nvn.8.h
include/nn/gfx/detail/gfx_Queue-api.nvn.8.h
include/nn/gfx/detail/gfx_RequiredMemory.h
include/nn/gfx/detail/gfx_ResShaderImpl.h
include/nn/gfx/detail/gfx_RootSignature-api.common.h
include/nn/gfx/detail/gfx_RootSignature-api.nvn.8.h
include/nn/gfx/detail/gfx_Sampler-api.nvn.8.h
include/nn/gfx/detail/gfx_Shader-api.nvn.8.h
include/nn/gfx/detail/gfx_State-api.nvn.8.h
include/nn/gfx/detail/gfx_SwapChain-api.nvn.8.h
include/nn/gfx/detail/gfx_Sync-api.nvn.8.h
include/nn/gfx/detail/gfx_Texture-api.nvn.8.h
include/nn/gfx/util/gfx_PrimitiveShape.h
include/nn/gfx/gfx_Buffer.h
include/nn/gfx/gfx_BufferData-api.nvn.8.h
include/nn/gfx/gfx_BufferInfo.h
include/nn/gfx/gfx_BufferInfoData.h
include/nn/gfx/gfx_CommandBuffer.h
include/nn/gfx/gfx_CommandBufferData-api.nvn.8.h
include/nn/gfx/gfx_CommandBufferInfo.h
include/nn/gfx/gfx_CommandBufferInfoData.h
include/nn/gfx/gfx_Common.h
include/nn/gfx/gfx_DescriptorPool.h
include/nn/gfx/gfx_DescriptorPoolData-api.nvn.8.h
include/nn/gfx/gfx_DescriptorPoolInfo.h
include/nn/gfx/gfx_DescriptorPoolInfoData.h
include/nn/gfx/gfx_DescriptorSlot.h
include/nn/gfx/gfx_Device.h
include/nn/gfx/gfx_DeviceData-api.nvn.8.h
include/nn/gfx/gfx_DeviceInfo.h
include/nn/gfx/gfx_DeviceInfoData.h
include/nn/gfx/gfx_Enum.h
include/nn/gfx/gfx_GpuAddress.h
include/nn/gfx/gfx_Interoperation-api.nvn.8.h
include/nn/gfx/gfx_MemoryPool.h
include/nn/gfx/gfx_MemoryPoolData-api.nvn.8.h
include/nn/gfx/gfx_MemoryPoolInfo.h
include/nn/gfx/gfx_MemoryPoolInfoData.h
include/nn/gfx/gfx_PipelineData-api.nvn.8.h
include/nn/gfx/gfx_Queue.h
include/nn/gfx/gfx_QueueData-api.nvn.8.h
include/nn/gfx/gfx_QueueInfo.h
include/nn/gfx/gfx_QueueInfoData.h
include/nn/gfx/gfx_ResShader.h
include/nn/gfx/gfx_ResShaderData-api.nvn.h
include/nn/gfx/gfx_ResShaderData.h
include/nn/gfx/gfx_ResTexture.h
include/nn/gfx/gfx_ResTextureData.h
include/nn/gfx/gfx_ResUserData.h
include/nn/gfx/gfx_ResUserDataData.h
include/nn/gfx/gfx_RootSignatureData-api.common.h
include/nn/gfx/gfx_RootSignatureInfo.h
include/nn/gfx/gfx_RootSignatureInfoData.h
include/nn/gfx/gfx_Sampler.h
include/nn/gfx/gfx_SamplerData-api.nvn.8.h
include/nn/gfx/gfx_SamplerInfo.h
include/nn/gfx/gfx_SamplerInfoData.h
include/nn/gfx/gfx_Shader.h
include/nn/gfx/gfx_ShaderData-api.nvn.8.h
include/nn/gfx/gfx_ShaderInfo.h
include/nn/gfx/gfx_ShaderInfoData.h
include/nn/gfx/gfx_State.h
include/nn/gfx/gfx_StateData-api.nvn.8.h
include/nn/gfx/gfx_StateInfo.h
include/nn/gfx/gfx_StateInfoData.h
include/nn/gfx/gfx_SwapChain.h
include/nn/gfx/gfx_SwapChainData-api.nvn.8.h
include/nn/gfx/gfx_SwapChainInfo.h
include/nn/gfx/gfx_SwapChainInfoData.h
include/nn/gfx/gfx_Sync.h
include/nn/gfx/gfx_SyncData-api.nvn.8.h
include/nn/gfx/gfx_SyncInfo.h
include/nn/gfx/gfx_SyncInfoData.h
include/nn/gfx/gfx_Texture.h
include/nn/gfx/gfx_TextureData-api.nvn.8.h
include/nn/gfx/gfx_TextureInfo.h
include/nn/gfx/gfx_TextureInfoData.h
include/nn/gfx/gfx_Types.h
include/nn/gfx/gfx_VariationBase.h
include/nn/fs/fs_bcat.h
include/nn/fs/fs_directories.h
include/nn/fs/fs_files.h
Expand All @@ -184,7 +250,14 @@ add_library(NintendoSDK OBJECT
include/nn/audio.h
include/nn/friends.h
include/nn/mem.h
include/nv.h

include/nvn/nvn_Cpp.h
include/nvn/nvn_CppFuncPtrBase.h
include/nvn/nvn_CppMethods.h
include/nvn/nvn_FuncPtrBase.h
include/nvn/nvn_FuncPtrInline.h
include/nvn/nvn.h

include/vapours/results.hpp
include/vapours/results/sf_results.hpp
include/vapours/results/capsrv_results.hpp
Expand Down Expand Up @@ -218,55 +291,50 @@ add_library(NintendoSDK OBJECT
include/vapours/results/fatal_results.hpp
include/vapours/results/sm_results.hpp
include/vapours/results/psc_results.hpp

src/NintendoSDK/gfx/detail/gfx_Buffer-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_CommandBuffer-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_CommonHelper.cpp
src/NintendoSDK/gfx/detail/gfx_CommonHelper.h
src/NintendoSDK/gfx/detail/gfx_DescriptorPool-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Device-api.nvn.8-os.horizon.cpp
src/NintendoSDK/gfx/detail/gfx_GlslcFunction.cpp
src/NintendoSDK/gfx/detail/gfx_MemoryPool-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_NvnHelper-os.horizon.cpp
src/NintendoSDK/gfx/detail/gfx_NvnHelper.cpp
src/NintendoSDK/gfx/detail/gfx_NvnHelper.h
src/NintendoSDK/gfx/detail/gfx_ResShader-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Sampler-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Shader-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_State-api.nvn.8.cpp
src/NintendoSDK/gfx/detail/gfx_Texture-api.nvn.8.cpp
src/NintendoSDK/gfx/util/gfx_ObjectDebugLabel-api.nvn.8.cpp
src/NintendoSDK/gfx/util/gfx_PrimitiveShape.cpp
src/NintendoSDK/gfx/gfx_BufferInfo.cpp
src/NintendoSDK/gfx/gfx_CommandBufferInfo.cpp
src/NintendoSDK/gfx/gfx_DescriptorPoolInfo.cpp
src/NintendoSDK/gfx/gfx_DeviceInfo.cpp
src/NintendoSDK/gfx/gfx_Interoperation-api.nvn.cpp
src/NintendoSDK/gfx/gfx_MemoryPoolInfo.cpp
src/NintendoSDK/gfx/gfx_QueueInfo.cpp
src/NintendoSDK/gfx/gfx_ResShader.cpp
src/NintendoSDK/gfx/gfx_ResTexture.cpp
src/NintendoSDK/gfx/gfx_SamplerInfo.cpp
src/NintendoSDK/gfx/gfx_ShaderInfo.cpp
src/NintendoSDK/gfx/gfx_StateInfo.cpp
src/NintendoSDK/gfx/gfx_SwapChainInfo.cpp
src/NintendoSDK/gfx/gfx_SyncInfo.cpp
src/NintendoSDK/gfx/gfx_TextureInfo.cpp
include/nv.h

src/NintendoSDK/nvn/nvn_CppFuncPtrImpl.h
src/NintendoSDK/nvn/nvn_FuncPtrImpl.h
src/NintendoSDK/nvn/nvn_Impl.cpp
src/NintendoSDK/nnSdk/util.cpp
)

target_include_directories(NintendoSDK PUBLIC include/)
target_include_directories(NintendoSDK PRIVATE src/NintendoSDK/)
target_compile_options(NintendoSDK PRIVATE -fno-strict-aliasing)
target_compile_options(NintendoSDK PRIVATE -fno-exceptions)
target_compile_options(NintendoSDK PRIVATE -Wall -Wextra)
target_compile_options(NintendoSDK PRIVATE -Wno-invalid-offsetof)

target_compile_definitions(NintendoSDK PRIVATE
NN_SDK_MAJOR=${NN_SDK_MAJOR}
NN_SDK_MINOR=${NN_SDK_MINOR}
NN_SDK_PATCH=${NN_SDK_PATCH}
NN_SDK_TYPE="${NN_SDK_TYPE}"
NN_WARE_MAJOR=${NN_WARE_MAJOR}
NN_WARE_MINOR=${NN_WARE_MINOR}
NN_WARE_PATCH=${NN_WARE_PATCH}
)
if(NN_USE_GFX)
target_compile_definitions(NintendoSDK PRIVATE NN_USE_GFX)
endif()

if (NN_API)
target_compile_definitions(NintendoSDK PRIVATE NN_API_${NN_API})
endif()

function(nn_ver ID)
set(VER ${${ID}})
string(REPLACE "." ";" VER "${VER}")

list(LENGTH VER SEGS)
if(SEGS LESS 3)
set(DEF_VER 1 0 0)
list(SUBLIST DEF_VER ${SEGS} -1 DEF_VER)
list(APPEND VER ${DEF_VER})

message(AUTHOR_WARNING "${ID} semver is not complete (%d.%d.%d): ${${ID}}")
endif()

list(POP_FRONT VER MAJOR MINOR PATCH)

foreach(VAR IN ITEMS MAJOR MINOR PATCH)
target_compile_definitions(NintendoSDK PRIVATE ${ID}_${VAR}=${${VAR}})
endforeach()
endfunction()

nn_ver(NN_WARE)
nn_ver(NN_SDK)
target_compile_definitions(NintendoSDK PRIVATE NN_SDK_TYPE="${NN_SDK_TYPE}")

Loading
Loading