Build: Add COMPONENT to all install() commands

This makes it possible for downstream packagers and other integrators of
libjpeg-turbo to include only specific directories from the
libjpeg-turbo installation (or to install specific directories under a
different prefix, etc.)  The names of the components correspond to the
directories into which they will be installed.

Refer to libvips/libvips#3931, #265, #338

Closes #756
This commit is contained in:
Kleis Auke Wolthuizen 2024-04-12 11:46:21 +02:00 committed by DRC
parent 6a522fcda4
commit 24e09baaf0
4 changed files with 44 additions and 35 deletions

View File

@ -1726,22 +1726,22 @@ set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
install(TARGETS turbojpeg EXPORT ${CMAKE_PROJECT_NAME}Targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
install(TARGETS tjbench
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin OPTIONAL)
endif()
endif()
if(ENABLE_STATIC)
install(TARGETS turbojpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
if(NOT ENABLE_SHARED)
if(GENERATOR_IS_MULTI_CONFIG)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@ -1749,17 +1749,17 @@ if(WITH_TURBOJPEG)
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(PROGRAMS ${DIR}/tjbench-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME tjbench${EXE})
endif()
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include)
endif()
if(ENABLE_STATIC)
install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
if(NOT ENABLE_SHARED)
if(GENERATOR_IS_MULTI_CONFIG)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@ -1767,15 +1767,16 @@ if(ENABLE_STATIC)
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(PROGRAMS ${DIR}/cjpeg-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME cjpeg${EXE})
install(PROGRAMS ${DIR}/djpeg-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME djpeg${EXE})
install(PROGRAMS ${DIR}/jpegtran-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME jpegtran${EXE})
endif()
endif()
install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS rdjpgcom wrjpgcom
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.c
@ -1783,10 +1784,11 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt
${CMAKE_CURRENT_SOURCE_DIR}/structure.txt
${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT doc)
if(WITH_JAVA)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java
DESTINATION ${CMAKE_INSTALL_DOCDIR})
DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc)
endif()
if(UNIX OR MINGW)
@ -1794,26 +1796,28 @@ if(UNIX OR MINGW)
${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1
${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT man)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib)
if(WITH_TURBOJPEG)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib)
endif()
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/${CMAKE_PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
COMPONENT lib)
install(EXPORT ${CMAKE_PROJECT_NAME}Targets
NAMESPACE ${CMAKE_PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
COMPONENT lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include)
include(cmakescripts/BuildPackages.cmake)

View File

@ -30,15 +30,15 @@ add_executable(cjpeg_fuzzer${FUZZER_SUFFIX} cjpeg.cc ../cdjpeg.c ../rdbmp.c
set_property(TARGET cjpeg_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
${COMPILE_FLAGS})
target_link_libraries(cjpeg_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY} jpeg-static)
install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
${FUZZ_BINDIR})
install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX}
RUNTIME DESTINATION ${FUZZ_BINDIR} COMPONENT bin)
macro(add_fuzz_target target source_file)
add_executable(${target}_fuzzer${FUZZER_SUFFIX} ${source_file})
target_link_libraries(${target}_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
turbojpeg-static)
install(TARGETS ${target}_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
${FUZZ_BINDIR})
install(TARGETS ${target}_fuzzer${FUZZER_SUFFIX}
RUNTIME DESTINATION ${FUZZ_BINDIR} COMPONENT bin)
endmacro()
add_fuzz_target(compress compress.cc)

View File

@ -89,5 +89,10 @@ GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_JAVADIR
set(CMAKE_INSTALL_JAVADIR ${CMAKE_INSTALL_JAVADIR} PARENT_SCOPE)
set(CMAKE_INSTALL_FULL_JAVADIR ${CMAKE_INSTALL_FULL_JAVADIR} PARENT_SCOPE)
report_directory(JAVADIR)
install_jar(turbojpeg-java ${CMAKE_INSTALL_JAVADIR})
if(CMAKE_VERSION VERSION_EQUAL "3.4" OR CMAKE_VERSION VERSION_GREATER "3.4")
install_jar(turbojpeg-java DESTINATION ${CMAKE_INSTALL_JAVADIR}
COMPONENT java)
else()
install_jar(turbojpeg-java ${CMAKE_INSTALL_JAVADIR})
endif()
mark_as_advanced(CLEAR CMAKE_INSTALL_JAVADIR)

View File

@ -119,14 +119,14 @@ add_executable(jcstest ../jcstest.c)
target_link_libraries(jcstest jpeg)
install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
install(TARGETS cjpeg djpeg jpegtran
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$<TARGET_PDB_FILE:jpeg>"
DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin OPTIONAL)
endif()