SDL_net icon indicating copy to clipboard operation
SDL_net copied to clipboard

.pc file is not installed with Debug build type

Open AMDmi3 opened this issue 1 year ago • 4 comments

I'm packaging SDL_net for FreeBSD and for that purpose I need it to install the same set of files regardless of debug/release build mode. For the context, we don't have separate debug/release packages, it's the single package which may be built in debug mode, and the packages built in either mode should be interchangeable. So library names should match and all files should be present regardless of the mode. It's possible to remove 'd' postfix with SDL2NET_DEBUG_POSTFIX knob, but .pc file is still not installed and the only way to fix that is to patch the CMakeLists.txt, which I believe should not be required. This may be fixed by either adding a knob which enables .pc file installation regardless of build type, or just switching to installing it unconditionally.

AMDmi3 avatar Aug 30 '22 17:08 AMDmi3

I think we can relax the check by always installing the sdl2_net.pc file when the debug postfix is empty. https://github.com/libsdl-org/SDL_net/blob/4faf9c80e58aaf119bf8ae8b164006bf57f897a1/CMakeLists.txt#L229-L238 =>

        install(CODE "
            if(CMAKE_INSTALL_CONFIG_NAME MATCHES \"Release\" OR NOT "${SDL2NET_DEBUG_POSTFIX}")
                # FIXME: use file(COPY_FILE) if minimum CMake version >= 3.21
                execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different
                    \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_net-$<CONFIG>.pc\"
                    \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_net.pc\")
                file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${PC_DESTDIR}\"
                    TYPE FILE
                    FILES \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_net.pc\")
            endif()" COMPONENT devel)

Would that work for your purpose? If it does, please open a pr :wink:

madebr avatar Aug 30 '22 17:08 madebr

I think we can just always install the pc file when building and installing the libraries, regardless of debug/release mode. @madebr, can you fix that for the SDL libraries?

slouken avatar Aug 30 '22 17:08 slouken

Would that work for your purpose?

It looks like it would, but I like @slouken's solution more for the simplicity:)

For the record, I also don't see much point in d suffix, as it does not resolve conflict between debug/release libraries, as other files (include, cmake) still conflict. And if these go into separate package, it won't be possible to link with one of the library versions anyway. Instead, having a suffix disallows interchanging the debug/release libraries, and forces one to rebuild the consumer app to switch from release to debug SDL_net or vice versa.

AMDmi3 avatar Aug 30 '22 18:08 AMDmi3

#61 addresses this. If you would be kind enough to test whether this fixes your issue.

madebr avatar Sep 01 '22 20:09 madebr

Fix confirmed, thank you!

AMDmi3 avatar Sep 02 '22 10:09 AMDmi3