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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/build
build/
/out
/lib/nnsdk
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.24)

project(NintendoWare C CXX)
set(NINTENDOWARE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

# Downstream projects should set something like:
# set(NN_WARE 1.2.3)
function(target_nn_ver LIB_TARGET SCOPE ID)
set(VER ${${ID}})
function(nnware_ver TARGET)
set(VER ${NN_WARE})
string(REPLACE "." ";" VER "${VER}")

list(LENGTH VER SEGS)
Expand All @@ -15,36 +14,42 @@ function(target_nn_ver LIB_TARGET SCOPE ID)
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}}")
message(AUTHOR_WARNING "NN_WARE semver is malformed (should be %d.%d.%d): ${NN_WARE}")
endif()

list(POP_FRONT VER MAJOR MINOR PATCH)

foreach(VAR IN ITEMS MAJOR MINOR PATCH)
target_compile_definitions(${LIB_TARGET} ${SCOPE} ${ID}_${VAR}=${${VAR}})
target_compile_definitions(${TARGET} PUBLIC NN_WARE_${VAR}=${${VAR}})
endforeach()
endfunction()

function(find_nnsdk)
if(NOT TARGET nnSdk)
if(DEFINED NNSDK_DIR)
if(IS_DIRECTORY "${NNSDK_DIR}")
message(STATUS "Found NintendoSDK: ${NNSDK_DIR}")
add_subdirectory(${NNSDK_DIR} ${NNSDK_DIR}/build)
else()
message(FATAL_ERROR "NNSDK_DIR is provided, but NintendoSDK is not found at: ${NNSDK_DIR}")
endif()
else()
message(FATAL_ERROR "NintendoSDK cannot be found. Ensure your project adds open-ead/nnsdk as a dependency (submodule), and your CMakeLists.txt contains `add_subdirectory(path/to/nnsdk)`")
endif()
endif()
# these flags are shared with all modules
set(NNWARE_COMPILE_FLAGS
-fno-strict-aliasing
-fno-exceptions
-Wall
-Wextra
-Wno-invalid-offsetof
# some WIP stuff might contain unused fields
-Wno-unused-private-field
)
function(nnware_header_verification_compile_options TARGET)
target_compile_options(${TARGET} INTERFACE
"$<$<STREQUAL:$<TARGET_PROPERTY:NAME>,${TARGET}_verify_interface_header_sets>:${NNWARE_COMPILE_FLAGS}>"
)
endfunction()

function(find_nnsdk_module NN_SDK_MODULE)
if(NOT TARGET ${NN_SDK_MODULE})
message(FATAL_ERROR "Cannot find ${NN_SDK_MODULE}. You appear to have a broken or unsupported NintendoSDK. Please use open-ead/nnsdk.")
if(NOT TARGET nnSdk)
if(NOT DEFINED NNSDK_DIR)
message(FATAL_ERROR "NintendoSDK cannot be found. Ensure your project adds open-ead/nnsdk as a dependency (submodule), and your CMakeLists.txt contains `add_subdirectory(path/to/nnsdk)`")
endif()
endfunction()
if(NOT IS_DIRECTORY "${NNSDK_DIR}")
message(FATAL_ERROR "NNSDK_DIR is provided, but NintendoSDK is not found at: ${NNSDK_DIR}")
endif()
message(STATUS "Found NintendoSDK: ${NNSDK_DIR}")
add_subdirectory(${NNSDK_DIR} nnsdk)
endif()

add_subdirectory(lib/atk)
add_subdirectory(lib/font)
Expand Down
15 changes: 14 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ tasks:
- task: cmake
vars:
CMAKE_ARGS: -DNNSDK_DIR=$(pwd)/lib/nnsdk
- >
cmake -G Ninja -B test/header_check/build -S test/header_check
-DNN_SDK=1.2.3
-DNN_WARE=4.5.6
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_FLAGS='-D__aarch64__'
-DCMAKE_CXX_FLAGS='-D__aarch64__'
-DNNSDK_DIR=$(pwd)/lib/nnsdk
cmake:
cmds:
- >
Expand All @@ -51,8 +62,9 @@ tasks:
vars:
VERIFY_TARGETS: '{{._MODULES2 | replace " " "" | replace "," "$ ^" | replace "^" "--target nn_" | replace "$" "_verify_interface_header_sets"}}'
cmds:
- cmake --build build
# the header check test already builds all the libs so we don't need an extra --build build here
- cmake --build build {{.VERIFY_TARGETS}}
- cmake --build test/header_check/build

check:
desc: Run clang-format and clang-tidy checks
Expand All @@ -77,6 +89,7 @@ tasks:
desc: Remove CMake build files
cmds:
- rm -rf build
- rm -rf test/*/build

clang-format:
cmds:
Expand Down
39 changes: 9 additions & 30 deletions lib/atk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
set(NN_ATK_HEADERS
include/nn/atk.h
include/nn/atk/atk_AuxBus.h
include/nn/atk/atk_SoundArchivePlayer.h
include/nn/atk/atk_SoundDataManager.h
include/nn/atk/atk_SoundPlayer.h
include/nn/atk/detail/atk_AdvancedWaveSoundRuntime.h
include/nn/atk/detail/atk_BasicSound.h
include/nn/atk/detail/atk_SequenceSoundRuntime.h
include/nn/atk/detail/atk_SoundArchiveManager.h
include/nn/atk/detail/atk_StreamSoundRuntime.h
include/nn/atk/detail/atk_WaveSoundRuntime.h
file(GLOB_RECURSE NN_ATK_HEADERS CONFIGURE_DEPENDS
include/*.h
)

set(NN_ATK_SOURCES
src/atk/atk_Stub.cpp
file(GLOB_RECURSE NN_ATK_SOURCES CONFIGURE_DEPENDS
src/*.cpp
)

add_library(nn_atk OBJECT ${NN_ATK_SOURCES})
add_library(nn_atk STATIC ${NN_ATK_SOURCES})

target_sources(nn_atk PUBLIC
FILE_SET HEADERS
BASE_DIRS include/
FILES ${NN_ATK_HEADERS}
)

set_target_properties(nn_atk PROPERTIES
LINKER_LANGUAGE CXX
VERIFY_INTERFACE_HEADER_SETS ON
)

target_include_directories(nn_atk PUBLIC include/)
set_target_properties(nn_atk PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)

target_nn_ver(nn_atk PUBLIC NN_WARE)
target_compile_options(nn_atk INTERFACE
-fno-strict-aliasing
-fno-exceptions
-Wall
-Wextra
-Wno-invalid-offsetof
)
nnware_ver(nn_atk)
target_compile_options(nn_atk PRIVATE ${NNWARE_COMPILE_FLAGS})
nnware_header_verification_compile_options(nn_atk)
29 changes: 9 additions & 20 deletions lib/font/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
set(NN_FONT_HEADERS
include/nn/font/font_Util.h
file(GLOB_RECURSE NN_FONT_HEADERS CONFIGURE_DEPENDS
include/*.h
)

set(NN_FONT_SOURCES
src/font/font_Stub.cpp
file(GLOB_RECURSE NN_FONT_SOURCES CONFIGURE_DEPENDS
src/*.cpp
)

add_library(nn_font OBJECT ${NN_FONT_SOURCES})
add_library(nn_font STATIC ${NN_FONT_SOURCES})

target_sources(nn_font PUBLIC
FILE_SET HEADERS
BASE_DIRS include/
FILES ${NN_FONT_HEADERS}
)

set_target_properties(nn_font PROPERTIES
LINKER_LANGUAGE CXX
VERIFY_INTERFACE_HEADER_SETS ON
)

target_include_directories(nn_font PUBLIC include/)
set_target_properties(nn_font PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)

target_nn_ver(nn_font PUBLIC NN_WARE)
target_compile_options(nn_font INTERFACE
-fno-strict-aliasing
-fno-exceptions
-Wall
-Wextra
-Wno-invalid-offsetof
)
nnware_ver(nn_font)
target_compile_options(nn_font PRIVATE ${NNWARE_COMPILE_FLAGS})
nnware_header_verification_compile_options(nn_font)
51 changes: 9 additions & 42 deletions lib/g3d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,22 @@
cmake_minimum_required(VERSION 3.15)

find_nnsdk()
find_nnsdk_module(nn_gfx)

set(NN_G3D_HEADERS
include/nn/g3d/g3d_ResMaterial.h
include/nn/g3d/g3d_ResLightAnim.h
include/nn/g3d/g3d_SkeletonObj.h
include/nn/g3d/g3d_ResFogAnim.h
include/nn/g3d/g3d_ResFile.h
include/nn/g3d/g3d_ResMaterialAnim.h
include/nn/g3d/g3d_ResSkeletalAnim.h
include/nn/g3d/g3d_ResShapeAnim.h
include/nn/g3d/g3d_ViewVolume.h
include/nn/g3d/g3d_ResSceneAnim.h
include/nn/g3d/g3d_ResSkeleton.h
include/nn/g3d/g3d_ModelObj.h
include/nn/g3d/g3d_BindFuncTable.h
include/nn/g3d/g3d_ResModel.h
include/nn/g3d/g3d_World.h
file(GLOB_RECURSE NN_G3D_HEADERS CONFIGURE_DEPENDS
include/*.h
)

set(NN_G3D_SOURCES
src/g3d/g3d_Stub.cpp
file(GLOB_RECURSE NN_G3D_SOURCES CONFIGURE_DEPENDS
src/*.cpp
)

add_library(nn_g3d OBJECT ${NN_G3D_SOURCES})
add_library(nn_g3d STATIC ${NN_G3D_SOURCES})

target_sources(nn_g3d PUBLIC
FILE_SET HEADERS
BASE_DIRS include/
FILES ${NN_G3D_HEADERS}
)

set_target_properties(nn_g3d PROPERTIES
LINKER_LANGUAGE CXX
VERIFY_INTERFACE_HEADER_SETS ON
)

target_include_directories(nn_g3d PUBLIC include/)
set_target_properties(nn_g3d PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)

target_nn_ver(nn_g3d PUBLIC NN_WARE)
target_nn_ver(nn_gfx PUBLIC NN_WARE)
target_nn_ver(nnSdk INTERFACE NN_WARE)
target_compile_options(nn_g3d INTERFACE
-fno-strict-aliasing
-fno-exceptions
-Wall
-Wextra
-Wno-invalid-offsetof
)
nnware_ver(nn_g3d)
target_compile_options(nn_g3d PRIVATE ${NNWARE_COMPILE_FLAGS})
nnware_header_verification_compile_options(nn_g3d)

target_link_libraries(nn_g3d PUBLIC nn_gfx)
target_link_libraries(nn_g3d PUBLIC nnSdk)
41 changes: 9 additions & 32 deletions lib/ui2d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
find_nnsdk()
find_nnsdk_module(nn_gfx)

set(NN_UI2D_HEADERS
include/nn/ui2d/detail/ui2d_TexCoordArray.h
include/nn/ui2d/ui2d_Layout.h
include/nn/ui2d/ui2d_Material.h
include/nn/ui2d/ui2d_Pane.h
include/nn/ui2d/ui2d_Parts.h
include/nn/ui2d/ui2d_Types.h
include/nn/ui2d/ui2d_Util.h
file(GLOB_RECURSE NN_UI2D_HEADERS CONFIGURE_DEPENDS
include/*.h
)

set(NN_UI2D_SOURCES
src/ui2d/ui2d_Stub.cpp
file(GLOB_RECURSE NN_UI2D_SOURCES CONFIGURE_DEPENDS
src/*.cpp
)

add_library(nn_ui2d OBJECT ${NN_UI2D_SOURCES})
add_library(nn_ui2d STATIC ${NN_UI2D_SOURCES})

target_sources(nn_ui2d PUBLIC
FILE_SET HEADERS
BASE_DIRS include/
FILES ${NN_UI2D_HEADERS}
)

set_target_properties(nn_ui2d PROPERTIES
LINKER_LANGUAGE CXX
VERIFY_INTERFACE_HEADER_SETS ON
)
set_target_properties(nn_ui2d PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)

target_include_directories(nn_ui2d PUBLIC include/)

target_nn_ver(nn_ui2d PUBLIC NN_WARE)
target_nn_ver(nn_gfx PUBLIC NN_WARE)
target_nn_ver(nnSdk INTERFACE NN_WARE)
target_compile_options(nn_ui2d INTERFACE
-fno-strict-aliasing
-fno-exceptions
-Wall
-Wextra
-Wno-invalid-offsetof
)
nnware_ver(nn_ui2d)
target_compile_options(nn_ui2d PRIVATE ${NNWARE_COMPILE_FLAGS})
nnware_header_verification_compile_options(nn_ui2d)

target_link_libraries(nn_ui2d PUBLIC nn_font)
target_link_libraries(nn_ui2d PUBLIC nn_gfx)
target_link_libraries(nn_ui2d PUBLIC nnSdk)
38 changes: 9 additions & 29 deletions lib/vfx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
find_nnsdk()
find_nnsdk_module(nn_gfx)

set(NN_VFX_HEADERS
include/nn/vfx/vfx_Config.h
include/nn/vfx/vfx_Heap.h
include/nn/vfx/vfx_Resource.h
include/nn/vfx/vfx_System.h
file(GLOB_RECURSE NN_VFX_HEADERS CONFIGURE_DEPENDS
include/*.h
)

set(NN_VFX_SOURCES
src/vfx/vfx_Stub.cpp
file(GLOB_RECURSE NN_VFX_SOURCES CONFIGURE_DEPENDS
src/*.cpp
)

add_library(nn_vfx OBJECT ${NN_VFX_SOURCES})
add_library(nn_vfx STATIC ${NN_VFX_SOURCES})

target_sources(nn_vfx PUBLIC
FILE_SET HEADERS
BASE_DIRS include/
FILES ${NN_VFX_HEADERS}
)

set_target_properties(nn_vfx PROPERTIES
LINKER_LANGUAGE CXX
VERIFY_INTERFACE_HEADER_SETS ON
)
set_target_properties(nn_vfx PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)

target_include_directories(nn_vfx PUBLIC include/)
nnware_ver(nn_vfx)
target_compile_options(nn_vfx PRIVATE ${NNWARE_COMPILE_FLAGS})
nnware_header_verification_compile_options(nn_vfx)

target_nn_ver(nn_vfx PUBLIC NN_WARE)
target_nn_ver(nn_gfx PUBLIC NN_WARE)
target_nn_ver(nnSdk INTERFACE NN_WARE)
target_compile_options(nn_vfx INTERFACE
-fno-strict-aliasing
-fno-exceptions
-Wall
-Wextra
-Wno-invalid-offsetof
)
target_link_libraries(nn_vfx PUBLIC nn_g3d)
target_link_libraries(nn_vfx PUBLIC nn_gfx)
target_link_libraries(nn_vfx PUBLIC nnSdk)
Loading
Loading