aboutsummaryrefslogtreecommitdiff
path: root/examples/beginner
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2021-10-15 09:22:45 +0800
committerGitHub <noreply@github.com>2021-10-15 09:22:45 +0800
commitdd0f088aaa4c6bf013643be2d1d8621dbffdb000 (patch)
treed848d6ce007d8bb9357c8b99d6a0a39ec41d244e /examples/beginner
parent9e08d1047fa8deeb3ccb3ce9bb11d69e25a52d56 (diff)
parenteb719a424e6a16fb64209139a32c9f8a7235a929 (diff)
downloadpsn00bsdk-dd0f088aaa4c6bf013643be2d1d8621dbffdb000.tar.gz
Merge pull request #38 from spicyjpeg/cmake
Full CMake support (in place of makefiles)
Diffstat (limited to 'examples/beginner')
-rw-r--r--examples/beginner/cppdemo/CMakeLists.txt22
-rw-r--r--examples/beginner/cppdemo/makefile65
-rw-r--r--examples/beginner/hello/CMakeLists.txt22
-rw-r--r--examples/beginner/hello/makefile65
4 files changed, 44 insertions, 130 deletions
diff --git a/examples/beginner/cppdemo/CMakeLists.txt b/examples/beginner/cppdemo/CMakeLists.txt
new file mode 100644
index 0000000..83f0f0a
--- /dev/null
+++ b/examples/beginner/cppdemo/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ cppdemo
+ LANGUAGES CXX
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK basic C++ example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.cpp)
+psn00bsdk_add_executable(cppdemo STATIC ${_sources})
+#psn00bsdk_add_cd_image(cppdemo_iso cppdemo iso.xml DEPENDS cppdemo)
+
+install(FILES ${PROJECT_BINARY_DIR}/cppdemo.exe DESTINATION .)
diff --git a/examples/beginner/cppdemo/makefile b/examples/beginner/cppdemo/makefile
deleted file mode 100644
index 630a280..0000000
--- a/examples/beginner/cppdemo/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = cppdemo
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/beginner/hello/CMakeLists.txt b/examples/beginner/hello/CMakeLists.txt
new file mode 100644
index 0000000..40e30b0
--- /dev/null
+++ b/examples/beginner/hello/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ hello
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK hello world example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(hello STATIC ${_sources})
+#psn00bsdk_add_cd_image(hello_iso hello iso.xml DEPENDS hello)
+
+install(FILES ${PROJECT_BINARY_DIR}/hello.exe DESTINATION .)
diff --git a/examples/beginner/hello/makefile b/examples/beginner/hello/makefile
deleted file mode 100644
index e4bed20..0000000
--- a/examples/beginner/hello/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = hello
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build