aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-07-07 13:22:53 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-11-11 00:08:15 +0100
commit7861a52adf92a083bb2aed4c35f98d8035dce032 (patch)
tree28cd3c40e4c878f730f5df3c1d93bdf91af490c3 /cmake
parent7fc48e9216ff809da5f8055a50b0be17628ef1df (diff)
downloadwnix-7861a52adf92a083bb2aed4c35f98d8035dce032.tar.gz
Setup project skeleton
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindPSXSDK.cmake94
-rw-r--r--cmake/FindWASI_SDK.cmake39
-rw-r--r--cmake/ps1.cmake29
3 files changed, 49 insertions, 113 deletions
diff --git a/cmake/FindPSXSDK.cmake b/cmake/FindPSXSDK.cmake
deleted file mode 100644
index 2d1982d..0000000
--- a/cmake/FindPSXSDK.cmake
+++ /dev/null
@@ -1,94 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#[=======================================================================[.rst:
-FindPSXSDK
------------
-
-Find PSXSDK (an open source software development kit for the original
-Sony PlayStation) libraries and header files.
-
-Imported targets
-^^^^^^^^^^^^^^^^
-
-This module defines the following :prop_tgt:`IMPORTED` targets:
-
- ``PSXSDK::PSXSDK``,
- The PSXSDK `psx` library, if found.
-
-Result variables
-^^^^^^^^^^^^^^^^
-
-This module will set the following variables in your project:
-
-``PSXSDK_FOUND``
- true if PSXSDK libraries and header files were found.
-``PSXSDK_VERSION``
- PSXSDK release version
-``PSXSDK_INCLUDE_DIRS``
- the directory containing the PSXSDK headers; note
- ``PSXSDK_INCLUDE_DIRS`` is also required
-``PSXSDK_LIBRARIES``
- PSXSDK libraries to be linked; note ``PSXSDK_LIBRARIES`` is also
- required
-
-#]=======================================================================]
-
-find_path(PSXSDK_INCLUDE_DIRS
- NAMES
- huff.h
- meidogte.h
- meidogte_inline.h
- memcard.h
- modplay.h
- psxbios.h
- psxcdrom.h
- psxgpu.h
- psxgte.h
- psx.h
- psxpad.h
- psxsio.h
- psxspu.h
- psxutil.h
- runexe.h
- search.h
- HINTS
- ENV PSXSDK_PATH
- PATH_SUFFIXES
- include
-)
-
-find_library(PSXSDK_LIBRARIES
- NAMES psx
- HINTS
- ENV PSXSDK_PATH
- PATH_SUFFIXES
- lib
-)
-
-if(PSXSDK_INCLUDE_DIRS AND EXISTS "${PSXSDK_INCLUDE_DIRS}/psx.h")
- set(version_regex "^#define[ \t]+PSXSDK_VERSION_STRING[ \t]+\"([0-9\.]+)\"$")
- file(STRINGS "${PSXSDK_INCLUDE_DIRS}/psx.h" PSXSDK_VERSION_LINE REGEX ${version_regex})
- string(REGEX REPLACE ${version_regex} "\\1" PSXSDK_VERSION "${PSXSDK_VERSION_LINE}")
- unset(PSXSDK_VERSION_LINE)
- unset(version_regex)
-endif()
-
-include(FindPackageHandleStandardArgs)
-
-find_package_handle_standard_args(PSXSDK
- REQUIRED_VARS
- PSXSDK_LIBRARIES PSXSDK_INCLUDE_DIRS
- VERSION_VAR
- PSXSDK_VERSION
-)
-
-if(PSXSDK_FOUND)
- if(NOT TARGET PSXSDK::PSXSDK)
- add_library(PSXSDK::PSXSDK INTERFACE IMPORTED)
- target_include_directories(PSXSDK::PSXSDK
- INTERFACE "${PSXSDK_INCLUDE_DIRS}")
- set_target_properties(PSXSDK::PSXSDK PROPERTIES
- IMPORTED_LOCATION "${PSXSDK_LIBRARIES}")
- endif()
-endif()
diff --git a/cmake/FindWASI_SDK.cmake b/cmake/FindWASI_SDK.cmake
new file mode 100644
index 0000000..28c7993
--- /dev/null
+++ b/cmake/FindWASI_SDK.cmake
@@ -0,0 +1,39 @@
+# wnix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+find_program(WASI_SDK_CLANG
+ clang
+ PATHS
+ /opt/wasi-sdk/bin
+ ENV WASI_SDK_PATH
+ NO_DEFAULT_PATH
+)
+
+find_program(WASI_SDK_STRIP
+ strip
+ PATHS
+ /opt/wasi-sdk/bin
+ ENV WASI_SDK_PATH
+ NO_DEFAULT_PATH
+)
+
+include(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(WASI_SDK
+ REQUIRED_VARS
+ WASI_SDK_CLANG
+ WASI_SDK_STRIP
+)
diff --git a/cmake/ps1.cmake b/cmake/ps1.cmake
index 21d77fa..14b6937 100644
--- a/cmake/ps1.cmake
+++ b/cmake/ps1.cmake
@@ -1,13 +1,8 @@
-find_package(PSXSDK 0.7.1 REQUIRED)
-
-target_compile_definitions(${PROJECT_NAME} PUBLIC FIXMATH_FAST_SIN PSXSDK_DEBUG)
-add_custom_target(exe ALL elf2exe ${PROJECT_NAME}
- ${cdroot}/${PROJECT_NAME}.exe -mark="A homebrew game created with PSXSDK"
+add_custom_target(exe ALL ${TOOLS_PREFIX}/bin/elf2exe ${PROJECT_NAME}
+ ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.exe
+ -mark="wnix, a Unix-like operating system for WebAssembly applications"
DEPENDS ${PROJECT_NAME})
-add_custom_target(iso ALL mkisofs -o ${PROJECT_NAME}.iso -V ${PROJECT_NAME}
- -sysid PLAYSTATION ${cdroot} DEPENDS exe)
-
-set(license_prefix $ENV{PSXSDK_PATH}/share/licenses)
+add_dependencies(exe tools)
if(VIDEO_MODE STREQUAL "VMODE_PAL")
set(region eur)
@@ -24,20 +19,16 @@ elseif(VIDEO_MODE STREQUAL "VMODE_NTSC")
set(region ${NTSC_REGION})
endif()
-set(license $ENV{PSXSDK_PATH}/share/licenses/info${region}.dat)
+add_custom_target(bin_cue ALL
+ ${TOOLS_PREFIX}/bin/mkpsxiso -q ${CMAKE_BINARY_DIR}/wnix.xml
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
-add_custom_target(bin_cue ALL mkpsxiso ${PROJECT_NAME}.iso ${PROJECT_NAME}.bin
- ${license} -s DEPENDS iso)
+add_dependencies(bin_cue exe tools)
-if(NOT EXISTS "${cdroot}/system.cnf")
- file(COPY "src/ps1/system.cnf" DESTINATION "${cdroot}")
-endif()
+set(cflags ${cflags})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(cflags ${cflags} -Og)
else()
- set(cflags ${cflags} -Os)
+ set(cflags ${cflags} -O3 -g)
endif()
-
-set(cflags ${cflags} -fshort-enums)
-# libfixmath is already bundled with PSXSDK.