Allow compilation and installation with cmake

This commit is contained in:
Crayon2000 2024-10-12 17:15:18 -04:00
parent d93847e6a3
commit 013da78dde
3 changed files with 84 additions and 10 deletions

View file

@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## [Unreleased][] ## [Unreleased][]
- Allow compilation and installation with cmake.
- Added `GRRLIB_CreateEmptyTextureFmt()` to create an empty texture with a given format. - Added `GRRLIB_CreateEmptyTextureFmt()` to create an empty texture with a given format.
## [4.5.1][] - 2024-03-02 ## [4.5.1][] - 2024-03-02

66
CMakeLists.txt Normal file
View file

@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.18)
project(grrlib)
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PNG REQUIRED libpng)
pkg_check_modules(FREETYPE REQUIRED freetype2)
pkg_check_modules(JPEG REQUIRED libjpeg)
add_library(pngu STATIC)
target_sources(pngu
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/GRRLIB/lib/pngu/pngu.c"
)
target_include_directories(pngu
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GRRLIB/lib/pngu>"
PRIVATE
${PNG_INCLUDE_DIRS}
)
target_link_libraries(pngu PUBLIC
${PNG_LIBRARIES}
)
add_library(grrlib STATIC)
target_compile_options(grrlib
PRIVATE
-Wall
-Wshadow
-Wunused
)
file(GLOB_RECURSE GRRLIB_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/GRRLIB/GRRLIB/*.c")
target_sources(grrlib
PRIVATE
"${GRRLIB_SRC_FILES}"
)
target_include_directories(grrlib
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GRRLIB/GRRLIB>"
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GRRLIB/GRRLIB/grrlib>"
${FREETYPE_INCLUDE_DIRS}
${JPEG_INCLUDE_DIRS}
)
target_link_libraries(grrlib PUBLIC
pngu
)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/GRRLIB/GRRLIB/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(TARGETS pngu grrlib
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

View file

@ -82,28 +82,35 @@ libjpeg is supplied via devkitPro pacman (ppc-libjpeg-turbo)
libfat is supplied via devkitPro pacman (libfat-ogc) libfat is supplied via devkitPro pacman (libfat-ogc)
``` ```
The easy way is to install GRRLIB and all the required libraries with a few First, you need to make sure that all required library dependencies are installed.
commands: Install them with a single command:
```bash
pacman --sync --needed --noconfirm libfat-ogc ppc-libpng ppc-freetype ppc-libjpeg-turbo
```
To install GRRLIB with Make in a few commands:
```bash ```bash
c: c:
cd \grr\GRRLIB cd \grr\GRRLIB
pacman --sync --needed --noconfirm libfat-ogc ppc-libpng ppc-freetype ppc-libjpeg-turbo
make clean all install make clean all install
``` ```
If you prefer to use CMake, it can also be installed with a few commands:
```bash
c:
cd \grr
/opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -B build
cmake --build build --target install
```
This process may take some time depending on the speed of your PC. This process may take some time depending on the speed of your PC.
If you used the method above the following steps are not required, GRRLIB is If you used the method above the following steps are not required, GRRLIB is
installed and you are ready to start developing Wii homebrew games. installed and you are ready to start developing Wii homebrew games.
If you want, you could install the libfat, libpng,
libfreetype and libjpeg with there dependencies in a single command:
```bash
pacman --sync --needed --noconfirm libfat-ogc ppc-libpng ppc-freetype ppc-libjpeg-turbo
```
Each library could also be installed individually: Each library could also be installed individually:
To install libpngu: To install libpngu: