Skip to content

Commit

Permalink
cmake: install licenses of vendored libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Dec 7, 2024
1 parent 9d303c3 commit 90bafc5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ if(SDLIMAGE_BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(install_license_names)
macro(register_license NAME FILE)
list(APPEND install_license_names ${NAME})
set(install_license_${NAME} "${FILE}")
endmacro()

set(INSTALL_EXTRA_TARGETS)
set(INSTALL_EXTRA_CMAKE_MODULES)
set(PC_LIBS)
Expand Down Expand Up @@ -380,6 +386,7 @@ if(SDLIMAGE_ZLIB)
set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "zlib examples" FORCE)
sdl_check_project_in_subfolder(external/zlib zlib SDLIMAGE_VENDORED)
add_subdirectory(external/zlib EXCLUDE_FROM_ALL)
register_license(zlib external/zlib/LICENSE)
# PNG_BUILD_ZLIB variable is used by vendored libpng
set(PNG_BUILD_ZLIB ON CACHE BOOL "libpng option to tell it should use 'our' vendored ZLIB library" FORCE)
# ZLIB_INCLUDE_DIR variable is used by vendored libpng
Expand Down Expand Up @@ -413,6 +420,7 @@ if(SDLIMAGE_DAV1D)
message(STATUS "${PROJECT_NAME}: Using vendored dav1d")
set(BUILD_SHARED_LIBS ${SDLIMAGE_DAV1D_SHARED})
add_subdirectory(external/dav1d EXCLUDE_FROM_ALL)
register_license(dav1d external/dav1d/COPYING)
if(DAV1D_ASM AND (SDL_CPU_X64 OR SDL_CPU_X86))
enable_language(ASM_NASM)
endif()
Expand Down Expand Up @@ -451,6 +459,7 @@ if(SDLIMAGE_AOM)
set(AOM_TARGET_CPU "aarch64")
endif()
add_subdirectory(external/aom EXCLUDE_FROM_ALL)
register_license(aom external/aom/LICENSE)
set(AOM_LIBRARY aom)
if(SDLIMAGE_AOM_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS aom)
Expand Down Expand Up @@ -479,6 +488,7 @@ if(SDLIMAGE_AVIF)
set(BUILD_SHARED_LIBS ${SDLIMAGE_AVIF_SHARED})
set(AOM_LIBRARIES "aom" CACHE STRING "aom libraries" FORCE)
add_subdirectory(external/libavif EXCLUDE_FROM_ALL)
register_license(avif external/libavif/LICENSE)
if(SDLIMAGE_AVIF_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS avif)
endif()
Expand Down Expand Up @@ -555,6 +565,7 @@ if(SDLIMAGE_JPG)
sdl_check_project_in_subfolder(external/jpeg libjpeg SDLIMAGE_VENDORED)
set(BUILD_SHARED_LIBS ${SDLIMAGE_JPG_SHARED})
add_subdirectory(external/jpeg EXCLUDE_FROM_ALL)
register_license(jpeg external/jpeg/COPYING)
if(SDLIMAGE_JPG_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS)
list(APPEND INSTALL_EXTRA_TARGETS jpeg)
endif()
Expand Down Expand Up @@ -625,6 +636,7 @@ if(SDLIMAGE_JXL)
sdl_check_project_in_subfolder(external/libjxl libjxl SDLIMAGE_VENDORED)
set(BUILD_SHARED_LIBS ${SDLIMAGE_JXL_SHARED})
add_subdirectory(external/libjxl EXCLUDE_FROM_ALL)
register_license(jxl external/libjxl/LICENSE)
if(SDLIMAGE_JXL_SHARED)
set(jxl_lib jxl)
set(jxl_install_libs brotlidec brotlicommon brotlienc jxl)
Expand Down Expand Up @@ -704,6 +716,7 @@ if(SDLIMAGE_PNG)
set(SKIP_INSTALL_EXPORT TRUE)
sdl_check_project_in_subfolder(external/libpng libpng SDLIMAGE_VENDORED)
add_subdirectory(external/libpng EXCLUDE_FROM_ALL)
register_license(zlib external/libpng/LICENSE)
if(SDLIMAGE_PNG_SHARED)
set(PNG_LIBRARY png_shared)
else()
Expand Down Expand Up @@ -825,6 +838,7 @@ if(SDLIMAGE_TIF)
sdl_check_project_in_subfolder(external/libtiff libtiff SDLIMAGE_VENDORED)
set(BUILD_SHARED_LIBS ${SDLIMAGE_TIF_SHARED})
add_subdirectory(external/libtiff EXCLUDE_FROM_ALL)
register_license(tiff external/libtiff/LICENSE.md)
add_library(TIFF::TIFF ALIAS tiff)
set(SDL2IMAGE_TIF_TARGET "TIFF::tiff")
if(SDLIMAGE_TIF_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -885,6 +899,7 @@ if(SDLIMAGE_WEBP)
sdl_check_project_in_subfolder(external/libwebp libwebp SDLIMAGE_VENDORED)
set(BUILD_SHARED_LIBS ${SDLIMAGE_WEBP_SHARED})
add_subdirectory(external/libwebp EXCLUDE_FROM_ALL)
register_license(webp external/libwebp/COPYING)
target_include_directories(${sdl3_image_target_name} PRIVATE external/libwebp/src)
add_library(WebP::webp ALIAS webp)
add_library(WebP::webpdemux ALIAS webpdemux)
Expand Down Expand Up @@ -1055,6 +1070,10 @@ if(SDLIMAGE_INSTALL)
COMPONENT library
)

foreach(license_name IN LISTS install_license_names)
install(FILES "${install_license_${license_name}}" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}/optional" RENAME "LICENSE.${license_name}.txt")
endforeach()

if(SDLIMAGE_INSTALL_CPACK)
if(MSVC)
set(CPACK_GENERATOR "ZIP")
Expand Down
6 changes: 4 additions & 2 deletions build-scripts/release-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@
"bin/aom.dll",
"bin/tiff.dll",
"bin/libwebp.dll",
"bin/libwebpdemux.dll"
"bin/libwebpdemux.dll",
"share/licenses/SDL3_image/optional/*.txt"
]
},
"files-devel": {
Expand All @@ -175,7 +176,8 @@
"bin/aom.dll",
"bin/tiff.dll",
"bin/libwebp.dll",
"bin/libwebpdemux.dll"
"bin/libwebpdemux.dll",
"share/licenses/SDL3_image/optional/*.txt"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion external/jpeg
Submodule jpeg updated 1 files
+34 −0 COPYING

0 comments on commit 90bafc5

Please sign in to comment.