mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2025-01-15 10:09:17 +00:00
➕ Add example which using CMake to build
This commit is contained in:
parent
57aa9ebb9c
commit
bc94c0f421
2 changed files with 59 additions and 0 deletions
39
examples/cmake/CMakeLists.txt
Normal file
39
examples/cmake/CMakeLists.txt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# Sets DEVKIT_PRO variable to directory with devkitPro
|
||||||
|
set(DEVKIT_PRO "/opt/devkitpro")
|
||||||
|
|
||||||
|
# Include needed to build with Wii toolchain
|
||||||
|
include("${DEVKIT_PRO}/cmake/Wii.cmake")
|
||||||
|
# Includes needed to find libraries needed by GRRLIB
|
||||||
|
include(FindZLIB)
|
||||||
|
include(FindJPEG)
|
||||||
|
include(FindPNG)
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# Your project details
|
||||||
|
project(
|
||||||
|
cmake # Your project name goes here
|
||||||
|
VERSION 0.1.0 # Your project version goes here
|
||||||
|
LANGUAGES C # Or CXX if you using C++
|
||||||
|
)
|
||||||
|
|
||||||
|
# Libraries required to link GRRLIB
|
||||||
|
find_package(Freetype REQUIRED)
|
||||||
|
find_package(BZip2 REQUIRED)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(JPEG REQUIRED)
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
|
||||||
|
# Finds some required libraries
|
||||||
|
file(GLOB libraries
|
||||||
|
"${DEVKIT_PRO}/portlibs/wii/lib/*.a" # GRRLIB
|
||||||
|
"${DEVKIT_PRO}/libogc/lib/wii/*.a" # libfat
|
||||||
|
)
|
||||||
|
|
||||||
|
# GRRLIB includes
|
||||||
|
include_directories("${DEVKIT_PRO}/portlibs/wii/include")
|
||||||
|
# Links the whole of libraries
|
||||||
|
link_libraries(${libraries} ${FREETYPE_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} -lfat)
|
||||||
|
|
||||||
|
# Here we go, builds executable
|
||||||
|
add_executable(cmake "src/main.c")
|
20
examples/cmake/src/main.c
Normal file
20
examples/cmake/src/main.c
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include <grrlib.h>
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initializes GRRLIB and WiiPad
|
||||||
|
GRRLIB_Init();
|
||||||
|
WPAD_Init();
|
||||||
|
|
||||||
|
GRRLIB_SetBackgroundColour(255, 0, 0, 1); // Sets the background color to red
|
||||||
|
|
||||||
|
// Main loop with the whole of content
|
||||||
|
while (1) {
|
||||||
|
GRRLIB_Render(); // Renders our content
|
||||||
|
}
|
||||||
|
|
||||||
|
GRRLIB_Exit(); // Finish GRRLIB work
|
||||||
|
exit(0); // Exit from executable
|
||||||
|
}
|
Loading…
Reference in a new issue