Skip to content

Commit

Permalink
Merge pull request #129 from HappySeaFox/fix/fix-release-debug-libs-#128
Browse files Browse the repository at this point in the history
Fix/fix release debug libs #128
  • Loading branch information
Dmitry Baryshev committed Oct 18, 2021
2 parents 36500f3 + 083f06e commit 987c987
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
19 changes: 15 additions & 4 deletions src/sail-codecs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,29 @@ if (SAIL_STATIC)
foreach (dependency IN LISTS SAIL_CODECS_FIND_DEPENDENCIES)
string(REPLACE "," ";" dependency ${dependency})
list(GET dependency 0 dependency_search_mechanism)
list(GET dependency 1 dependency_name)
list(GET dependency 2 dependency_link_target)

if (dependency_search_mechanism STREQUAL "find_dependency")
list(GET dependency 1 dependency_name)
list(GET dependency 2 dependency_link_target)

set(SAIL_CODECS_FIND_DEPENDENCIES_EXPANDED "${SAIL_CODECS_FIND_DEPENDENCIES_EXPANDED}
find_dependency(${dependency_name} REQUIRED)
set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${dependency_link_target})
")
elseif(dependency_search_mechanism STREQUAL "find_library")
list(GET dependency 1 dependency_release_name)
list(GET dependency 2 dependency_debug_name)
set(dependency_name ${dependency_release_name})

set(SAIL_CODECS_FIND_DEPENDENCIES_EXPANDED "${SAIL_CODECS_FIND_DEPENDENCIES_EXPANDED}
find_library(${dependency_name}_LIBRARY ${dependency_name} REQUIRED)
set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES \${${dependency_name}_LIBRARY})
find_library(${dependency_name}_RELEASE_LIBRARY NAMES ${dependency_release_name})
find_library(${dependency_name}_DEBUG_LIBRARY NAMES ${dependency_debug_name} ${dependency_release_name})
if (NOT ${dependency_name}_RELEASE_LIBRARY OR NOT ${dependency_name}_DEBUG_LIBRARY)
message(FATAL_ERROR \"Missing dependency: ${dependency_name}\")
endif()
set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES \$<\$<CONFIG:Release>:\${${dependency_name}_RELEASE_LIBRARY}> \$<\$<CONFIG:Debug>:\${${dependency_name}_DEBUG_LIBRARY}>)
")
else()
message(FATAL_ERROR "Unsupported dependencies search mechanism '${dependency_search_mechanism}'")
Expand Down
14 changes: 9 additions & 5 deletions src/sail-codecs/jpeg2000/jpeg2000.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
macro(sail_find_dependencies)
find_library(JPEG2000_LIBRARY jasper)
find_library(JPEG2000_RELEASE_LIBRARY NAMES jasper)
find_library(JPEG2000_DEBUG_LIBRARY NAMES jasperd jasper)
find_path(JPEG2000_INCLUDE_DIRS jasper/jasper.h)

if (NOT JPEG2000_LIBRARY OR NOT JPEG2000_INCLUDE_DIRS)
if ((NOT JPEG2000_RELEASE_LIBRARY AND NOT JPEG2000_DEBUG_LIBRARY) OR NOT JPEG2000_INCLUDE_DIRS)
return()
endif()

set(JPEG2000_LIBRARY optimized ${JPEG2000_RELEASE_LIBRARY} debug ${JPEG2000_DEBUG_LIBRARY})

set(sail_jpeg2000_include_dirs ${JPEG2000_INCLUDE_DIRS})
set(sail_jpeg2000_libs ${JPEG2000_LIBRARY})

# This will add the following CMake rules to the CMake config for static builds so a client
# application links against the required dependencies:
#
# find_library(jasper_LIBRARY jasper REQUIRED)
# set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${jasper_LIBRARY})
# find_library(jasper_RELEASE_LIBRARY NAMES jasper)
# find_library(jasper_DEBUG_LIBRARY NAMES jasperd jasper)
# set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<$<CONFIG:Release>:${jasper_RELEASE_LIBRARY}> $<$<CONFIG:Debug>:${jasper_DEBUG_LIBRARY}>)
#
set(SAIL_CODECS_FIND_DEPENDENCIES ${SAIL_CODECS_FIND_DEPENDENCIES} "find_library,jasper," PARENT_SCOPE)
set(SAIL_CODECS_FIND_DEPENDENCIES ${SAIL_CODECS_FIND_DEPENDENCIES} "find_library,jasper,jasperd" PARENT_SCOPE)
endmacro()
7 changes: 4 additions & 3 deletions src/sail-codecs/svg/svg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ macro(sail_find_dependencies)
# This will add the following CMake rules to the CMake config for static builds so a client
# application links against the required dependencies:
#
# find_dependency(SVG_LIBRARY resvg REQUIRED)
# set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${SVG_LIBRARY})
# find_library(resvg_RELEASE_LIBRARY NAMES resvg)
# find_library(resvg_DEBUG_LIBRARY NAMES resvg)
# set_property(TARGET SAIL::sail-codecs APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<$<CONFIG:Release>:${resvg_RELEASE_LIBRARY}> $<$<CONFIG:Debug>:${resvg_DEBUG_LIBRARY}>)
#
set(SAIL_CODECS_FIND_DEPENDENCIES ${SAIL_CODECS_FIND_DEPENDENCIES} "find_library,resvg," PARENT_SCOPE)
set(SAIL_CODECS_FIND_DEPENDENCIES ${SAIL_CODECS_FIND_DEPENDENCIES} "find_library,resvg,resvg" PARENT_SCOPE)
endmacro()
11 changes: 8 additions & 3 deletions src/sail-codecs/webp/webp.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
macro(sail_find_dependencies)
find_library(WEBP_LIBRARY webp)
find_library(WEBP_DEMUX_LIBRARY webpdemux)
find_library(WEBP_RELEASE_LIBRARY NAMES webp)
find_library(WEBP_DEBUG_LIBRARY NAMES webpd webp)
find_library(WEBP_DEMUX_RELEASE_LIBRARY NAMES webpdemux)
find_library(WEBP_DEMUX_DEBUG_LIBRARY NAMES webpdemuxd webpdemux)
find_path(WEBP_INCLUDE_DIRS webp/decode.h)

if (NOT WEBP_LIBRARY OR NOT WEBP_DEMUX_LIBRARY OR NOT WEBP_INCLUDE_DIRS)
if ((NOT WEBP_RELEASE_LIBRARY AND NOT WEBP_DEBUG_LIBRARY) OR (NOT WEBP_DEMUX_RELEASE_LIBRARY AND NOT WEBP_DEMUX_DEBUG_LIBRARY) OR NOT WEBP_INCLUDE_DIRS)
return()
endif()

set(WEBP_LIBRARY optimized ${WEBP_RELEASE_LIBRARY} debug ${WEBP_DEBUG_LIBRARY})
set(WEBP_DEMUX_LIBRARY optimized ${WEBP_DEMUX_RELEASE_LIBRARY} debug ${WEBP_DEMUX_DEBUG_LIBRARY})

set(sail_webp_include_dirs ${WEBP_INCLUDE_DIRS})
set(sail_webp_libs ${WEBP_LIBRARY} ${WEBP_DEMUX_LIBRARY})

Expand Down

0 comments on commit 987c987

Please sign in to comment.