pspdev / psplibraries

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

Modified list of implicitly linked libraries in PSP.cmake #57

Closed dbeef closed 4 years ago

dbeef commented 4 years ago

This is to use Joel16's SDL2 port from https://github.com/pspdev/psplibraries/pull/45 without explicitly linking to PSP-SDK libraries.

Test snippet:

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)
add_executable(test-cmake main.cpp)

target_link_libraries(test-cmake PRIVATE /home/dbeef/joel16-SDL2/libSDL2main.a SDL2)

create_pbp_file(
    TARGET test-cmake 
    ICON_PATH NULL 
    BACKGROUND_PATH NULL
    PREVIEW_PATH NULL
)

main.cpp

#include <SDL2/SDL.h>

extern "C"
{
    int SDL_main(int argc, char *argv[])
    {
        while(true){}
    }
}

I passed absolute path to libSDL2main.a as it's not currently built and installed by default, there's an ongoing work on fixing this.

dbeef commented 4 years ago

Relevant MR:

https://github.com/joel16/SDL2/pull/1

carstene1ns commented 4 years ago

What I dislike here is that you push your very specific use case (-> using SDL) to all possible users of cmake building. There are some others options, not involving SDL. I agree, that we cannot make this work without headache for everyone, but "one thing to do it right for everyone" is a concept that does not work.

dbeef commented 4 years ago

I see your point, but the libraries that I add are still from within the core PSP SDK - they won't conflict with anyone's dependencies, and linking them in correct order is already troubling, so that's a time saver.

sharkwouter commented 4 years ago

This change did make me able to build a small SDL2 game I started working on a while back using the following CMakeLists.txt file: https://github.com/sharkwouter/jewelpop/blob/master/CMakeLists.txt

It builds for both Linux and PSP without additional changes now.

carstene1ns commented 4 years ago

@dbeef: I see your point. My idea is here that SDL2 should specify the needed libraries, so they get pulled in there. @sharkwouter: Of course it does. So does likely many others (based on SDL). However, overlinking occurs when you use a different library that does not need the same dependencies.

dbeef commented 4 years ago

After discussions it was decided to not add PSP_LIBRARIES to cmake's global link flags, and instead, serve them as a variable so anyone interested would link them via:

target_link_libraries(sometarget ${PSP_LIBRARIES})

Will commit relevant changes in a moment.