mirror of
https://github.com/gbdev/rgbds.git
synced 2026-03-25 14:23:04 +00:00
Use imported targets for linking to libpng
This massively simplifies the process lol
This commit is contained in:
@@ -123,7 +123,8 @@ if(MSVC OR NOT PKG_CONFIG_FOUND)
|
|||||||
# this is most evident on macOS but can occur on Linux too
|
# this is most evident on macOS but can occur on Linux too
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
else()
|
else()
|
||||||
pkg_check_modules(LIBPNG REQUIRED libpng)
|
pkg_check_modules(LIBPNG REQUIRED IMPORTED_TARGET libpng)
|
||||||
|
add_library(PNG::PNG ALIAS PkgConfig::LIBPNG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories("include")
|
include_directories("include")
|
||||||
|
|||||||
@@ -108,13 +108,4 @@ install(TARGETS rgbasm rgblink rgbfix rgbgfx RUNTIME)
|
|||||||
set_target_properties(rgbasm rgblink rgbfix rgbgfx PROPERTIES
|
set_target_properties(rgbasm rgblink rgbfix rgbgfx PROPERTIES
|
||||||
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
|
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
|
||||||
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}>)
|
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}>)
|
||||||
|
target_link_libraries(rgbgfx PRIVATE PNG::PNG)
|
||||||
if(LIBPNG_FOUND) # pkg-config
|
|
||||||
target_include_directories(rgbgfx PRIVATE ${LIBPNG_INCLUDE_DIRS})
|
|
||||||
target_link_directories(rgbgfx PRIVATE ${LIBPNG_LIBRARY_DIRS})
|
|
||||||
target_link_libraries(rgbgfx PRIVATE ${LIBPNG_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_compile_definitions(rgbgfx PRIVATE ${PNG_DEFINITIONS})
|
|
||||||
target_include_directories(rgbgfx PRIVATE ${PNG_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(rgbgfx PRIVATE ${PNG_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|||||||
@@ -9,18 +9,8 @@ add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
|
|||||||
set_target_properties(randtilegen rgbgfx_test PROPERTIES
|
set_target_properties(randtilegen rgbgfx_test PROPERTIES
|
||||||
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
|
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
|
||||||
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/gfx>)
|
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/gfx>)
|
||||||
|
target_link_libraries(randtilegen PRIVATE PNG::PNG)
|
||||||
foreach(TARGET randtilegen rgbgfx_test)
|
target_link_libraries(rgbgfx_test PRIVATE PNG::PNG)
|
||||||
if(LIBPNG_FOUND) # pkg-config
|
|
||||||
target_include_directories(${TARGET} PRIVATE ${LIBPNG_INCLUDE_DIRS})
|
|
||||||
target_link_directories(${TARGET} PRIVATE ${LIBPNG_LIBRARY_DIRS})
|
|
||||||
target_link_libraries(${TARGET} PRIVATE ${LIBPNG_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_compile_definitions(${TARGET} PRIVATE ${PNG_DEFINITIONS})
|
|
||||||
target_include_directories(${TARGET} PRIVATE ${PNG_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(${TARGET} PRIVATE ${PNG_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(ONLY_FREE)
|
set(ONLY_FREE)
|
||||||
if(NOT TESTS_RUN_NONFREE)
|
if(NOT TESTS_RUN_NONFREE)
|
||||||
|
|||||||
Reference in New Issue
Block a user