Merge pull request #75 from madebr/pr69extra

cmake: build examples on all platforms + no more need for FindNXGL for Nintendo Switch
This commit is contained in:
aap 2021-06-29 11:46:54 +02:00 committed by GitHub
commit b2ceadc9f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 333 additions and 281 deletions

View File

@ -59,10 +59,10 @@ jobs:
fi
- name: "Export Playstation 2 CMake toolchain conan recipe"
run: |
conan export cmake/ps2toolchain ps2dev-cmaketoolchain/master@
conan export cmake/ps2/cmaketoolchain ps2dev-cmaketoolchain/master@
- name: "Download/build dependencies (conan install)"
run: |
conan install ${{ github.workspace }} librw/master@ -if build -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib}} --build missing -pr:h ./host_profile -pr:b default
conan install ${{ github.workspace }} librw/master@ -if build -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib }} --build missing -pr:h ./host_profile -pr:b default
env:
CONAN_SYSREQUIRES_MODE: enabled
- name: "Build librw (conan build)"

View File

@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- name: "Build files"
run: |
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -S. -Bbuild .. -DLIBRW_PLATFORM=GL3 -DLIBRW_GL3_GFXLIB=GLFW -DLIBRW_INSTALL=True
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -S. -Bbuild -DLIBRW_PLATFORM=GL3 -DLIBRW_GL3_GFXLIB=GLFW -DLIBRW_INSTALL=True
cmake --build build --parallel
- name: "Create binary package (cpack)"
working-directory: ./build

3
.gitignore vendored
View File

@ -6,4 +6,5 @@
/.vs
librw.vcxproj.user
librw.VC.db
librw.VC.VC.opendb
librw.VC.VC.opendb
imgui.ini

View File

@ -13,10 +13,15 @@ if(WIN32)
elseif(NINTENDO_SWITCH)
set(LIBRW_PLATFORMS "NULL" "GL3")
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/nxtoolchain")
include(CheckNXFunctions)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/nx")
include(NXFunctions)
elseif(PS2)
set(LIBRW_PLATFORMS "NULL" "PS2")
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/ps2")
include(PS2Functions)
else()
set(LIBRW_PLATFORMS "NULL" "GL3" "PS2")
set(LIBRW_PLATFORMS "NULL" "GL3")
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL ON)
endif()
set(LIBRW_PLATFORM "NULL" CACHE STRING "Platform")
@ -41,8 +46,16 @@ if(LIBRW_PLATFORM_PS2)
enable_language(DSM)
endif()
if(NOT COMMAND librw_platform_target)
function(librw_platform_target)
endfunction()
endif()
include(CMakeDependentOption)
option(LIBRW_TOOLS "Build librw tools" ON)
option(LIBRW_INSTALL "Install librw files" OFF)
cmake_dependent_option(LIBRW_EXAMPLES "Build librw examples" ON "NOT LIBRW_PLATFORM_PS2;NOT LIBRW_PLATFORM_NULL" OFF)
if(LIBRW_INSTALL)
include(GNUInstallDirs)
@ -51,12 +64,12 @@ endif()
add_subdirectory(src)
if(LIBRW_TOOLS)
if(NOT LIBRW_PLATFORM_PS2 AND NOT LIBRW_PLATFORM_NULL)
add_subdirectory(skeleton)
add_subdirectory(tools)
endif()
add_subdirectory(tools)
if(LIBRW_INSTALL)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/librw-config.cmake.in librw-config.cmake
@ -77,12 +90,6 @@ if(LIBRW_INSTALL)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
)
endif()
if(NINTENDO_SWITCH)
install(
FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/nxtoolchain/FindNXGL.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
)
endif()
string(REPLACE "." ";" cmake_c_compiler_version_list "${CMAKE_C_COMPILER_VERSION}")
list(GET cmake_c_compiler_version_list 0 cmake_c_compiler_version_major)

9
README.cmake Normal file
View File

@ -0,0 +1,9 @@
Build with cmake
================
Linux
mkdir build
cd build
cmake .. -DLIBRW_PLATFORM=GL3 -DLIBRW_GL3_GFXLIB=SDL2
make

View File

@ -3,19 +3,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/librw-targets.cmake")
set(LIBRW_PLATFORM "@LIBRW_PLATFORM@")
set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@")
set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON)
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL @LIBRW_PLATFORM_GL3_REQUIRES_OPENGL@)
if(LIBRW_PLATFORM_GL3)
set(LIBRW_GL3_GFXLIB "@LIBRW_GL3_GFXLIB@")
set(LIBRW_GL3_GFXLIBS "@LIBRW_GL3_GFXLIBS@")
if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
endif()
if(NINTENDO_SWITCH)
find_package(NXGL REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL)
if(NOT TARGET TARGET OpenGL::OpenGL AND NOT TARGET OpenGL::EGL AND NOT TARGET OpenGL::GL)
message(FATAL_ERROR )
endif()
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
find_package(glfw3 REQUIRED)
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2")

View File

@ -0,0 +1,37 @@
if(NOT COMMAND nx_generate_nacp)
message(FATAL_ERROR "The `nx_generate_nacp` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()
if(NOT COMMAND nx_create_nro)
message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
function(librw_platform_target TARGET)
cmake_parse_arguments(LPT "INSTALL" "" "" ${ARGN})
get_target_property(TARGET_TYPE "${TARGET}" TYPE)
if(TARGET_TYPE STREQUAL "EXECUTABLE")
nx_generate_nacp(${TARGET}.nacp
NAME "${TARGET}"
AUTHOR "${librw_AUTHOR}"
VERSION "${librw_VERSION}"
)
nx_create_nro(${TARGET}
NACP ${TARGET}.nacp
)
if(LIBRW_INSTALL AND LPT_INSTALL)
get_target_property(TARGET_OUTPUT_NAME ${TARGET} OUTPUT_NAME)
if(NOT TARGET_OUTPUT_NAME)
set(TARGET_OUTPUT_NAME "${TARGET}")
endif()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_OUTPUT_NAME}.nro"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()
endif()
endfunction()

View File

@ -1,7 +0,0 @@
if(NOT COMMAND nx_generate_nacp)
message(FATAL_ERROR "The `nx_generate_nacp` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()
if(NOT COMMAND nx_create_nro)
message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.")
endif()

View File

@ -1,38 +0,0 @@
find_library(NXGL_EGL_LIBRARY EGL)
find_library(NXGL_GLAPI_LIBRARY glapi)
find_library(NXGL_DRM_NOUVEAU_LIBRARY drm_nouveau)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NXGL
REQUIRED_VARS NXGL_EGL_LIBRARY NXGL_GLAPI_LIBRARY NXGL_DRM_NOUVEAU_LIBRARY
)
if(NXGL_FOUND)
if(NOT TARGET NXGL::EGL)
add_library(NXGL::EGL UNKNOWN IMPORTED)
set_target_properties(NXGL::EGL PROPERTIES
IMPORTED_LOCATION "${NXGL_EGL_LIBRARY}"
)
endif()
if(NOT TARGET NXGL::glapi)
add_library(NXGL::glapi UNKNOWN IMPORTED)
set_target_properties(NXGL::glapi PROPERTIES
IMPORTED_LOCATION "${NXGL_GLAPI_LIBRARY}"
)
endif()
if(NOT TARGET NXGL::drm_nouveau)
add_library(NXGL::drm_nouveau UNKNOWN IMPORTED)
set_target_properties(NXGL::drm_nouveau PROPERTIES
IMPORTED_LOCATION "${NXGL_DRM_NOUVEAU_LIBRARY}"
)
endif()
if(NOT TARGET NXGL::OpenGL)
add_library(NXGL::OpenGL INTERFACE IMPORTED)
set_target_properties(NXGL::OpenGL PROPERTIES
INTERFACE_LINK_LIBRARIES "NXGL::EGL;NXGL::glapi;NXGL::drm_nouveau"
)
endif()
endif()

View File

@ -0,0 +1,18 @@
if(NOT COMMAND add_erl_executable)
message(FATAL_ERROR "The `add_erl_executable` cmake command is not available. Please use an appropriate Playstation 2 toolchain.")
endif()
function(librw_platform_target TARGET)
cmake_parse_arguments(LPT "INSTALL" "" "" ${ARGN})
get_target_property(TARGET_TYPE "${TARGET}" TYPE)
if(TARGET_TYPE STREQUAL "EXECUTABLE")
add_erl_executable(${TARGET} OUTPUT_VAR ERL_FILE)
if(LIBRW_INSTALL AND LPT_INSTALL)
install(FILES "${ERL_FILE}"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()
endif()
endfunction()

View File

@ -18,4 +18,7 @@ class Ps2devCMakeToolchainConan(ConanFile):
def package_info(self):
self.user_info.cmake_dir = os.path.join(self.package_folder, "cmake").replace("\\", "/")
self.user_info.cmake_toolchain_file = os.path.join(self.package_folder, "cmake", "cmaketoolchain.cmake").replace("\\", "/")
cmake_toolchain_file = os.path.join(self.package_folder, "cmake", "toolchain_ps2_ee.cmake").replace("\\", "/")
self.user_info.cmake_toolchain_file = cmake_toolchain_file
self.cpp_info.CONAN_CMAKE_TOOLCHAIN_FILE = cmake_toolchain_file

View File

@ -45,7 +45,7 @@ set(CMAKE_C_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}
set(CMAKE_CXX_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-G0 -L\"${PS2SDK}/ee/lib\" -Wl,-r -Wl,-d")
set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee;${PS2SDK}/ee")
set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee" "${PS2SDK}/ee")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
@ -53,9 +53,19 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(PS2 1)
set(EE 1)
function(add_erl_executable OUTFILE TARGET)
get_property(output_dir TARGET ${TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY)
set(outfile "${output_dir}/${TARGET}.erl")
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
function(add_erl_executable TARGET)
cmake_parse_arguments("AEE" "" "OUTPUT_VAR" "" ${ARGN})
get_target_property(output_dir ${TARGET} RUNTIME_OUTPUT_DIRECTORY)
get_target_property(output_name ${TARGET} OUTPUT_NAME)
if(NOT output_name)
set(output_name ${TARGET})
endif()
set(outfile "${output_dir}/${output_name}.erl")
add_custom_command(OUTPUT "${outfile}"
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${TARGET}>" "${outfile}"
COMMAND "${CMAKE_STRIP}" --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment "${outfile}"
@ -64,5 +74,8 @@ function(add_erl_executable OUTFILE TARGET)
add_custom_target("${TARGET}_erl" ALL
DEPENDS "${outfile}"
)
set("${OUTFILE}" "${outfile}" PARENT_SCOPE)
if(AEE_OUTPUT_VAR)
set("${AEE_OUTPUT_VAR}" "${outfile}" PARENT_SCOPE)
endif()
endfunction()

View File

@ -1,60 +0,0 @@
cmake_minimum_required(VERSION 3.7)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
set(CMAKE_SYSTEM_NAME "PlayStation2")
set(CMAKE_SYSTEM_PROCESSOR "mipsel")
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
if(NOT DEFINED ENV{PS2DEV})
message(FATAL_ERROR "Need environment variable PS2DEV set")
endif()
if(NOT DEFINED ENV{PS2SDK})
message(FATAL_ERROR "Need environment variable PS2SDK set")
endif()
set(PS2DEV "$ENV{PS2DEV}")
set(PS2SDK "$ENV{PS2SDK}")
set(CMAKE_DSM_SOURCE_FILE_EXTENSIONS "dsm")
set(CMAKE_C_COMPILER "${PS2DEV}/ee/bin/ee-gcc")
set(CMAKE_CXX_COMPILER "${PS2DEV}/ee/bin/ee-g++")
set(CMAKE_ASM_COMPILER "${PS2DEV}/ee/bin/ee-g++")
set(CMAKE_DSM_COMPILER "${PS2DEV}/dvp/bin/dvp-as")
set(CMAKE_AR "${PS2DEV}/ee/bin/ee-ar" CACHE FILEPATH "archiver")
set(CMAKE_LINKER "${PS2DEV}/ee/bin/ee-ld")
set(CMAKE_RANLIB "${PS2DEV}/ee/bin/ee-ranlib" CACHE FILEPATH "ranlib")
set(CMAKE_STRIP "${PS2DEV}/ee/bin/ee-strip" CACHE FILEPATH "strip")
set(CMAKE_ASM_FLAGS_INIT "-G0 -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"")
set(CMAKE_C_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"")
set(CMAKE_CXX_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-G0 -L\"${PS2SDK}/ee/lib\" -Wl,-r -Wl,-d")
set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee;${PS2SDK}/ee")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(PS2 1)
set(EE 1)
function(add_erl_executable OUTFILE TARGET)
get_property(output_dir TARGET ${TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY)
set(outfile "${output_dir}/${TARGET}.erl")
add_custom_command(OUTPUT "${outfile}"
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${TARGET}>" "${outfile}"
COMMAND "${CMAKE_STRIP}" --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment "${outfile}"
DEPENDS ${TARGET}
)
add_custom_target("${TARGET}_erl" ALL
DEPENDS "${outfile}"
)
set("${OUTFILE}" "${outfile}" PARENT_SCOPE)
endfunction()

View File

@ -36,6 +36,7 @@ class LibrwConan(ConanFile):
if self._os_is_playstation2:
self.options.platform = "ps2"
if self.settings.os == "Windows":
self.options.platform = "d3d9"
self.options["sdl2"].directx = False
def configure(self):
@ -44,13 +45,10 @@ class LibrwConan(ConanFile):
def validate(self):
if self.options.platform == "d3d9" and self.settings.os != "Windows":
raise ConanInvalidConfiguration("d3d9 can only be built for Windows")
if self.options.platform == "ps2":
if not self._os_is_playstation2:
raise ConanInvalidConfiguration("platform=ps2 is only valid for os=Playstation2")
else:
if self._os_is_playstation2:
raise ConanInvalidConfiguration("os=Playstation2 only supports platform=ps2")
raise ConanInvalidConfiguration("platform=d3d9 can only be built for os=Windows")
if self._os_is_playstation2:
if self.options.platform not in ("null", "ps2"):
raise ConanInvalidConfiguration("os=Playstation2 only supports platform=(null,ps2)")
def requirements(self):
if self.options.platform == "gl3":
@ -114,7 +112,6 @@ class LibrwConan(ConanFile):
if self.options.platform == "gl3":
cmake.definitions["LIBRW_GL3_GFXLIB"] = str(self.options.gl3_gfxlib).upper()
if self._os_is_playstation2:
cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = self.deps_user_info["ps2dev-cmaketoolchain"].cmake_toolchain_file
env["PS2SDK"] = self.deps_cpp_info["ps2dev-ps2sdk"].rootpath
with tools.environment_append(env):
cmake.configure(source_folder=self.build_folder)

View File

@ -1,42 +1,68 @@
add_library(librw_skeleton
glfw.cpp
sdl2.cpp
skeleton.cpp
skeleton.h
win.cpp
glfw.cpp
sdl2.cpp
skeleton.cpp
skeleton.h
win.cpp
imgui/imconfig.h
imgui/imgui.cpp
imgui/imgui_demo.cpp
imgui/imgui_draw.cpp
imgui/imgui.h
imgui/imgui_impl_rw.cpp
imgui/imgui_impl_rw.h
imgui/imgui_internal.h
imgui/ImGuizmo.cpp
imgui/ImGuizmo.h
imgui/stb_rect_pack.h
imgui/stb_textedit.h
imgui/stb_truetype.h
)
add_library(librw::skeleton ALIAS librw_skeleton)
set_target_properties(librw_skeleton
PROPERTIES
PREFIX ""
EXPORT_NAME skeleton
)
target_link_libraries(librw_skeleton
PUBLIC
PRIVATE
librw
)
target_include_directories(librw_skeleton
INTERFACE
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${LIBRW_INSTALL_INCLUDEDIR}/skeleton>
)
if(NOT LIBRW_PLATFORM_PS2 AND NOT LIBRW_PLATFORM_NULL)
add_subdirectory(imgui)
endif()
if(LIBRW_INSTALL)
target_include_directories(librw_skeleton
INTERFACE
$<INSTALL_INTERFACE:${LIBRW_INSTALL_INCLUDEDIR}/skeleton>
)
install(
FILES
skeleton.h
DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/skeleton"
)
install(
FILES
imgui/imconfig.h
imgui/imgui.h
imgui/imgui_impl_rw.h
imgui/imgui_internal.h
imgui/ImGuizmo.h
imgui/stb_textedit.h
DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/skeleton/imgui"
)
install(
FILES
imgui/LICENSE_imgui.txt
imgui/LICENSE_imguizmo.txt
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
)
install(
TARGETS librw_skeleton
EXPORT librw-targets

View File

@ -1,46 +0,0 @@
add_library(librw_skeleton_imgui
imconfig.h
imgui.cpp
imgui_demo.cpp
imgui_draw.cpp
imgui.h
imgui_impl_rw.cpp
imgui_impl_rw.h
imgui_internal.h
ImGuizmo.cpp
ImGuizmo.h
stb_rect_pack.h
stb_textedit.h
stb_truetype.h
)
set_target_properties(librw_skeleton_imgui
PROPERTIES
PREFIX ""
)
target_link_libraries(librw_skeleton_imgui
PUBLIC
librw_skeleton
)
if(LIBRW_INSTALL)
install(
FILES
imconfig.h
imgui.h
imgui_impl_rw.h
imgui_internal.h
ImGuizmo.h
stb_textedit.h
DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/skeleton/imgui"
)
install(
TARGETS librw_skeleton_imgui
EXPORT librw-targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif()

View File

@ -100,6 +100,7 @@ add_library(librw::librw ALIAS librw)
target_include_directories(librw
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${LIBRW_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(librw
@ -148,16 +149,6 @@ set_target_properties(librw
)
if(LIBRW_PLATFORM_GL3)
if(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
target_link_libraries(librw
PUBLIC
OpenGL::GL
)
endif()
if (LIBRW_GL3_GFXLIB STREQUAL "GLFW")
find_package(glfw3 REQUIRED)
target_link_libraries(librw
@ -171,35 +162,37 @@ if(LIBRW_PLATFORM_GL3)
PUBLIC
SDL2::SDL2
)
if(TARGET SDL2::SDL2main)
target_link_libraries(librw
PUBLIC
SDL2::SDL2main
)
endif()
endif()
if(NINTENDO_SWITCH)
find_package(NXGL REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL)
if(TARGET OpenGL::OpenGL)
target_link_libraries(librw
PUBLIC
NXGL::OpenGL
PRIVATE
OpenGL::OpenGL
)
elseif(TARGET OpenGL::EGL)
target_link_libraries(librw
PRIVATE
OpenGL::EGL
)
elseif(TARGET OpenGL::GL)
target_link_libraries(librw
PRIVATE
OpenGL::GL
)
else()
message(FATAL_ERROR "find_package(OpenGL) failed.")
endif()
elseif(LIBRW_PLATFORM_D3D9)
target_link_libraries(librw
PUBLIC
PRIVATE
d3d9
xinput
)
endif()
if(LIBRW_INSTALL)
target_include_directories(librw
INTERFACE
$<INSTALL_INTERFACE:${LIBRW_INSTALL_INCLUDEDIR}>
)
install(
FILES
"${PROJECT_SOURCE_DIR}/args.h"

View File

@ -1,11 +1,20 @@
if(NOT LIBRW_PLATFORM_PS2)
if(LIBRW_TOOLS AND NOT LIBRW_PLATFORM_PS2)
add_subdirectory(dumprwtree)
add_subdirectory(ska2anm)
endif()
if(TARGET librw_skeleton_imgui)
add_subdirectory(imguitest)
endif()
if(LIBRW_EXAMPLES)
if(TARGET librw::skeleton)
add_subdirectory(imguitest)
add_subdirectory(playground)
add_subdirectory(lights)
add_subdirectory(subrast)
add_subdirectory(camera)
add_subdirectory(im2d)
add_subdirectory(im3d)
endif()
if(LIBRW_PLATFORM_PS2)
add_subdirectory(ps2test)
if(LIBRW_PLATFORM_PS2)
add_subdirectory(ps2test)
endif()
endif()

View File

@ -0,0 +1,18 @@
add_executable(camera WIN32
main.cpp
camexamp.cpp
viewer.cpp
)
target_link_libraries(camera
PRIVATE
librw::skeleton
librw::librw
)
add_custom_command(
TARGET camera POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/files" "$<TARGET_FILE_DIR:camera>/files"
)
librw_platform_target(camera)

View File

@ -3,8 +3,8 @@ add_executable(dumprwtree
)
target_link_libraries(dumprwtree
PUBLIC
librw
PRIVATE
librw::librw
)
if(LIBRW_INSTALL)
@ -13,20 +13,4 @@ if(LIBRW_INSTALL)
)
endif()
if(NINTENDO_SWITCH)
nx_generate_nacp(dumprwtree.nacp
NAME "dumprwtree"
AUTHOR "${librw_AUTHOR}"
VERSION "${librw_VERSION}"
)
nx_create_nro(dumprwtree
NACP dumprwtree.nacp
)
if(LIBRW_INSTALL)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dumprwtree.nro"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()
endif()
librw_platform_target(dumprwtree INSTALL)

22
tools/im2d/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
add_executable(im2d WIN32
im2d.cpp
linelist.cpp
main.cpp
polyline.cpp
trifan.cpp
trilist.cpp
tristrip.cpp
)
target_link_libraries(im2d
PRIVATE
librw::skeleton
librw::librw
)
add_custom_command(
TARGET im2d POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/files" "$<TARGET_FILE_DIR:im2d>/files"
)
librw_platform_target(im2d)

22
tools/im3d/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
add_executable(im3d WIN32
im3d.cpp
linelist.cpp
main.cpp
polyline.cpp
trifan.cpp
trilist.cpp
tristrip.cpp
)
target_link_libraries(im3d
PRIVATE
librw::skeleton
librw::librw
)
add_custom_command(
TARGET im3d POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/files" "$<TARGET_FILE_DIR:im3d>/files"
)
librw_platform_target(im3d)

View File

@ -4,8 +4,8 @@ add_executable(imguitest WIN32
target_link_libraries(imguitest
PUBLIC
librw
librw_skeleton_imgui
librw::skeleton
librw::librw
)
if(LIBRW_INSTALL)
@ -14,20 +14,4 @@ if(LIBRW_INSTALL)
)
endif()
if(NINTENDO_SWITCH)
nx_generate_nacp(imguitest.nacp
NAME "librw imguitest"
AUTHOR "${librw_AUTHOR}"
VERSION "${librw_VERSION}"
)
nx_create_nro(imguitest
NACP imguitest.nacp
)
if(LIBRW_INSTALL)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/imguitest.nro"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()
endif()
librw_platform_target(imguitest INSTALL)

View File

@ -0,0 +1,17 @@
add_executable(lights WIN32
main.cpp
lights.cpp
)
target_link_libraries(lights
PRIVATE
librw::skeleton
librw::librw
)
add_custom_command(
TARGET lights POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/checker.dff" "$<TARGET_FILE_DIR:lights>"
)
librw_platform_target(lights)

View File

@ -0,0 +1,21 @@
add_executable(playground WIN32
camera.cpp
font.cpp
main.cpp
ras_test.cpp
splines.cpp
tl_tests.cpp
)
target_link_libraries(playground
PRIVATE
librw::skeleton
librw::librw
)
add_custom_command(
TARGET playground POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/teapot.dff" "${CMAKE_CURRENT_SOURCE_DIR}/maze.tga" "${CMAKE_CURRENT_SOURCE_DIR}/Bm437_IBM_VGA8.FON" "${CMAKE_CURRENT_SOURCE_DIR}/Bm437_IBM_BIOS.FON" "$<TARGET_FILE_DIR:playground>"
)
librw_platform_target(playground)

View File

@ -258,7 +258,7 @@ InitRW(void)
tex = rw::Texture::read("maze", nil);
tex2 = rw::Texture::read("checkers", nil);
const char *filename = "teapot2.dff";
const char *filename = "teapot.dff";
if(sk::args.argc > 1)
filename = sk::args.argv[1];
rw::StreamFile in;

View File

@ -8,18 +8,15 @@ add_executable(ps2test
)
target_link_libraries(ps2test
PUBLIC
librw
PRIVATE
librw::librw
kernel
)
add_erl_executable(PS2TEST_ERL ps2test)
librw_platform_target(ps2test)
if(LIBRW_INSTALL)
install(TARGETS ps2test
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(FILES "${PS2TEST_ERL}"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

View File

@ -0,0 +1,16 @@
add_executable(ska2anm
ska2anm.cpp
)
target_link_libraries(ska2anm
PUBLIC
librw::librw
)
librw_platform_target(ska2anm INSTALL)
if(LIBRW_INSTALL)
install(TARGETS ska2anm
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

View File

@ -0,0 +1,11 @@
add_executable(subrast WIN32
main.cpp subrast.cpp
)
target_link_libraries(subrast
PUBLIC
librw::skeleton
librw::librw
)
librw_platform_target(subrast)