diff --git a/examples/cmake/CMakeLists.txt b/examples/cmake/CMakeLists.txt new file mode 100644 index 0000000..b2cbfed --- /dev/null +++ b/examples/cmake/CMakeLists.txt @@ -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") diff --git a/examples/cmake/src/main.c b/examples/cmake/src/main.c new file mode 100644 index 0000000..21b8352 --- /dev/null +++ b/examples/cmake/src/main.c @@ -0,0 +1,20 @@ +#include +#include +#include + +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 +}