pspdev / psplibraries

A script to automatically build open-source libraries for PSP homebrew development.
47 stars 45 forks source link

Updated cmake toolchain file. #52

Closed dbeef closed 4 years ago

dbeef commented 4 years ago

I wanted to share CreatePBP.cmake, which I previously wrote for my Spelunky-PSP project. It defines a cmake macro for creating PSP executables.

Now, the shortest working example that you can write and run on PSP would be:

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)
add_executable(test-cmake main.cpp)
target_link_libraries(test-cmake PRIVATE SDL SDLmain)
create_pbp_file(
    TARGET test-cmake 
    ICON_PATH NULL 
    BACKGROUND_PATH NULL
    PREVIEW_PATH NULL
)

main.cpp

#include <SDL/SDL.h>
extern "C"
{
    int SDL_main(int argc, char *argv[])
    {
        while(true){}
    }
}

built with:

mkdir build
cd build
psp-cmake ..
cmake --build . 

CreatePBP macro arguments are optional, so the sample call can be boiled down to:

create_pbp_file(TARGET test-cmake)

But I wanted to show all possible arguments.

Besides the macro, I updated the cmake toolchain file PSP.cmake with a mix of the one from Daedalus project by Wally4000 and my changes made in Spelunky-PSP toolchain.

Squash before merging!

dbeef commented 4 years ago

For now I still need to test this, but I did add some comments. Is the EBOOT.PBP always created or do you need to use a command for that?

You need to do it explicitly by calling in your project's CMakeLists.txt:

create_pbp_file(test-cmake NULL NULL)

Just like in included sample.

dbeef commented 4 years ago

I added preview_path argument to the create_pbp_file macro.

Arguments are represented as following:

image

dbeef commented 4 years ago

I was under impression that we ship SDL2 already - because of that, I updated the example I provide in description to use SDL 1.25 instead.

(I had this yet experimental SDL2 built from https://github.com/joel16/SDL2)

dbeef commented 4 years ago

Sorry for the long time spent resolving your discussions, didn't feel well and just left this for the weekend.

Right now all of them are addressed.