Skip to content

[libpng] Different rules to link against libpng on different platforms #14930

@HappySeaFox

Description

@HappySeaFox

Is your feature request related to a problem? Please describe.
Linking against libpng requires different cmake commands on different platforms. On Windows it's

    find_package(libpng CONFIG REQUIRED)
    target_link_libraries(main PRIVATE png)

On Linux:

    find_package(libpng CONFIG REQUIRED)
    target_link_libraries(main PRIVATE png_static)

Proposed solution
Fix libpng to export the same cmake commands to include libpng in a cross-platform project. For example, like we do with libpng-turbo:

find_package(JPEG REQUIRED)
target_link_libraries(main PRIVATE ${JPEG_LIBRARIES})
target_include_directories(main PRIVATE ${JPEG_INCLUDE_DIR})

Describe alternatives you've considered
if/else branching:

if (WIN32)
    find_package(libpng CONFIG REQUIRED)
    target_link_libraries(main PRIVATE png)
else()
    find_package(libpng CONFIG REQUIRED)
    target_link_libraries(main PRIVATE png_static)
endif()

Additional context
None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions