Skip to content

Commit

Permalink
fix cmake for EXR
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldsmith committed Feb 7, 2025
1 parent 19c65e1 commit 7b9ee39
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 82 deletions.
4 changes: 2 additions & 2 deletions src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if( OJPH_ENABLE_TIFF_SUPPORT AND (NOT EMSCRIPTEN))
message(STATUS " TIFF_LIBRARIES = ${TIFF_LIBRARIES}")
endif(TIFF_FOUND)

endif(OJPH_ENABLE_TIFF_SUPPORT)
endif(OJPH_ENABLE_TIFF_SUPPORT AND (NOT EMSCRIPTEN))
############################################################

# Add OPENEXR library
Expand Down Expand Up @@ -51,7 +51,7 @@ if( OJPH_ENABLE_OPENEXR_SUPPORT )
message(STATUS " found OpenEXR with FindModule")
endif(OpenEXR_FOUND_WITH_CONFIG)
else(OpenEXR_FOUND)
message(STATUS "OpenEXR support has been enabled but no path to the OpenEXR or IlmBase library "
message(STATUS "OpenEXR support has been requested but no path to the OpenEXR or IlmBase library "
"has been specified; please configure with -DCMAKE_PREFIX_PATH=<OpenEXR library directory>, "
"or disable OpenEXR support using -DOJPH_ENABLE_OpenEXR_SUPPORT=OFF.")
endif(OpenEXR_FOUND)
Expand Down
94 changes: 54 additions & 40 deletions src/apps/ojph_compress/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,52 +44,66 @@ else()

endif()

add_executable(ojph_compress ${SOURCES})
# add_executable(ojph_compress ${SOURCES})

if( USE_TIFF )
if( USE_OPENEXR )
target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}
# For OpenEXR/Imath 3.x:
$<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# For OpenEXR 2.4/2.5:
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
else()
target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES})
endif()
else()
if( USE_OPENEXR )
target_link_libraries(ojph_compress PUBLIC openjph
# For OpenEXR/Imath 3.x:
$<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# For OpenEXR 2.4/2.5:
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
else()
target_link_libraries(ojph_compress PUBLIC openjph)
endif()
endif()
# if( USE_TIFF )
# if( USE_OPENEXR )
# target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES}
# # For OpenEXR/Imath 3.x:
# $<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
# $<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
# $<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# # For OpenEXR 2.4/2.5:
# $<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
# $<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
# $<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
# $<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
# $<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# # ZLIB for OpenEXR 2.x:
# $<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
# else()
# target_link_libraries(ojph_compress PUBLIC openjph ${TIFF_LIBRARIES})
# endif()
# else()
# if( USE_OPENEXR )
# target_link_libraries(ojph_compress PUBLIC openjph
# # For OpenEXR/Imath 3.x:
# $<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
# $<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
# $<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# # For OpenEXR 2.4/2.5:
# $<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
# $<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
# $<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
# $<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
# $<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# # ZLIB for OpenEXR 2.x:
# $<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
# else()
# target_link_libraries(ojph_compress PUBLIC openjph)
# endif()
# endif()

install(TARGETS ojph_compress DESTINATION bin)
# install(TARGETS ojph_compress DESTINATION bin)
endif()

add_executable(ojph_compress ${SOURCES})
target_include_directories(ojph_compress PRIVATE ../common)
target_link_libraries(ojph_compress PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
target_link_libraries(ojph_compress PRIVATE openjph
#TIFF
$<TARGET_NAME_IF_EXISTS:TIFF::TIFF>
# For OpenEXR/Imath 3.x:
$<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# For OpenEXR 2.4/2.5:
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)

install(TARGETS ojph_compress
EXPORT openjph-config
Expand Down
94 changes: 54 additions & 40 deletions src/apps/ojph_expand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,52 +44,66 @@ else()

endif()

add_executable(ojph_expand ${SOURCES})
# add_executable(ojph_expand ${SOURCES})

if( USE_TIFF )
if( USE_OPENEXR )
target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}
# For OpenEXR/Imath 3.x:
$<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# For OpenEXR 2.4/2.5:
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
else()
target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES})
endif()
else()
if( USE_OPENEXR )
target_link_libraries(ojph_expand PUBLIC openjph
# For OpenEXR/Imath 3.x:
$<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# For OpenEXR 2.4/2.5:
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
else()
target_link_libraries(ojph_expand PUBLIC openjph)
endif()
endif()
# if( USE_TIFF )
# if( USE_OPENEXR )
# target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES}
# # For OpenEXR/Imath 3.x:
# $<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
# $<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
# $<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# # For OpenEXR 2.4/2.5:
# $<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
# $<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
# $<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
# $<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
# $<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# # ZLIB for OpenEXR 2.x:
# $<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
# else()
# target_link_libraries(ojph_expand PUBLIC openjph ${TIFF_LIBRARIES})
# endif()
# else()
# if( USE_OPENEXR )
# target_link_libraries(ojph_expand PUBLIC openjph
# # For OpenEXR/Imath 3.x:
# $<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
# $<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
# $<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# # For OpenEXR 2.4/2.5:
# $<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
# $<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
# $<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
# $<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
# $<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# # ZLIB for OpenEXR 2.x:
# $<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)
# else()
# target_link_libraries(ojph_expand PUBLIC openjph)
# endif()
# endif()

install(TARGETS ojph_expand DESTINATION bin)
# install(TARGETS ojph_expand DESTINATION bin)
endif()

add_executable(ojph_expand ${SOURCES})
target_include_directories(ojph_expand PRIVATE ../common)
target_link_libraries(ojph_expand PRIVATE openjph $<TARGET_NAME_IF_EXISTS:TIFF::TIFF>)
target_link_libraries(ojph_expand PRIVATE openjph
# TIFF
$<TARGET_NAME_IF_EXISTS:TIFF::TIFF>
# For OpenEXR/Imath 3.x:
$<$<TARGET_EXISTS:OpenEXR::OpenEXR>:OpenEXR::OpenEXR>
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
# For OpenEXR 2.4/2.5:
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>)

install(TARGETS ojph_expand
EXPORT openjph-config
Expand Down

0 comments on commit 7b9ee39

Please sign in to comment.