Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add options for optional deps and find them after installation #354

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fix: fix finding the libpng
aminya committed Jun 14, 2023
commit ed3d1c4044efc2e3e283fca86a1ad5c0af8bc3af
16 changes: 11 additions & 5 deletions source/3rd_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -99,12 +99,18 @@ endif()

if(MATPLOTPP_WITH_PNG)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(libpng)
if(NOT libpng_FOUND)
find_package(PNG REQUIRED)
endif()
else()
find_package(ZLIB QUIET)
find_package(PNG QUIET)
find_package(libpng QUIET)
if(NOT libpng_FOUND)
find_package(PNG QUIET)
endif()
endif()
if(ZLIB_FOUND AND PNG_FOUND)
if(ZLIB_FOUND AND (libpng_FOUND OR PNG_FOUND))
target_compile_definitions(cimg INTERFACE cimg_use_zlib cimg_use_png)
if (NOT TARGET ZLIB::ZLIB)
add_library(ZLIB::ZLIB INTERFACE)
@@ -115,8 +121,8 @@ if(ZLIB_FOUND AND PNG_FOUND)
target_link_libraries(cimg INTERFACE ZLIB::ZLIB)
if (NOT TARGET png)
add_library(png INTERFACE)
target_include_directories(png INTERFACE ${PNG_INCLUDE_DIRS})
target_link_libraries(cimg INTERFACE ${PNG_LIBRARIES})
target_include_directories(png INTERFACE ${libpng_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS})
target_link_libraries(cimg INTERFACE ${libpng_LIBRARIES} ${PNG_LIBRARIES})
list(APPEND EXPORTED_TARGETS png)
endif()
target_link_libraries(cimg INTERFACE png)