#200 Fixed installation directory

This commit is contained in:
vincent-richard 2021-05-06 21:06:47 +02:00
parent c6904bd7cf
commit 7503cd3747

View File

@ -69,6 +69,27 @@ PROJECT(
VERSION ${VMIME_VERSION}
)
# Install directories
IF(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
SET(VMIME_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
ELSE()
SET(VMIME_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
ENDIF()
MESSAGE("CMAKE_INSTALL_LIBDIR='${CMAKE_INSTALL_LIBDIR}")
MESSAGE("VMIME_INSTALL_LIBDIR='${VMIME_INSTALL_LIBDIR}")
IF(IS_ABSOLUTE ${CMAKE_INSTALL_BINDIR})
SET(VMIME_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
ELSE()
SET(VMIME_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
ENDIF()
IF(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
SET(VMIME_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
ELSE()
SET(VMIME_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
ENDIF()
# Set base name
SET(VMIME_LIBRARY_NAME vmime)
SET(VMIME_LIBRARY_VENDOR Kisli)
@ -211,24 +232,32 @@ IF(VMIME_BUILD_STATIC_LIBRARY)
SET_TARGET_PROPERTIES(${VMIME_LIBRARY_NAME}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
ENDIF()
SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
# Installation of libraries
IF(VMIME_BUILD_SHARED_LIBRARY)
INSTALL(
TARGETS ${VMIME_LIBRARY_NAME}
EXPORT ${VMIME_LIBRARY_NAME}-config
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT sharedlibs
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT sharedlibs
LIBRARY DESTINATION "${VMIME_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${VMIME_INSTALL_INCLUDEDIR}"
COMPONENT sharedlibs
)
INSTALL(
EXPORT ${VMIME_LIBRARY_NAME}-config
DESTINATION "${VMIME_INSTALL_LIBDIR}/cmake/vmime"
)
ENDIF()
IF(VMIME_BUILD_STATIC_LIBRARY)
INSTALL(
TARGETS ${VMIME_LIBRARY_NAME}-static
EXPORT ${VMIME_LIBRARY_NAME}-config
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT staticlibs
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT staticlibs
EXPORT ${VMIME_LIBRARY_NAME}-static-config
ARCHIVE DESTINATION "${VMIME_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${VMIME_INSTALL_INCLUDEDIR}"
COMPONENT staticlibs
)
INSTALL(
EXPORT ${VMIME_LIBRARY_NAME}-static-config
DESTINATION "${VMIME_INSTALL_LIBDIR}/cmake/vmime"
)
ENDIF()
@ -236,14 +265,6 @@ ENDIF()
INSTALL_HEADERS_WITH_DIRECTORY(VMIME_LIBRARY_INCLUDE_FILES headers "${CMAKE_CURRENT_SOURCE_DIR}/src/")
INSTALL_HEADERS_WITH_DIRECTORY(VMIME_LIBRARY_GENERATED_INCLUDE_FILES headers "${CMAKE_BINARY_DIR}/src")
#INSTALL(
# FILES ${VMIME_LIBRARY_INCLUDE_FILES}
# DESTINATION include
# COMPONENT headers
#)
install(EXPORT ${VMIME_LIBRARY_NAME}-config DESTINATION cmake)
##############################################################################
# Tests
@ -404,9 +425,9 @@ ADD_CUSTOM_TARGET(
# PkgConfig
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
SET(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/vmime)
SET(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
SET(exec_prefix ${VMIME_INSTALL_BINDIR})
SET(includedir ${VMIME_INSTALL_INCLUDEDIR}/vmime)
SET(libdir ${VMIME_INSTALL_LIBDIR})
SET(VMIME_PKGCONFIG_LIBS "")
SET(VMIME_PKGCONFIG_CFLAGS "")
@ -1029,7 +1050,13 @@ CONFIGURE_FILE(cmake/config.hpp.cmake ${CMAKE_BINARY_DIR}/src/vmime/config.hpp)
# PkgConfig post-configuration
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/vmime.pc.in ${CMAKE_BINARY_DIR}/vmime.pc @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/vmime.pc DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT headers)
INSTALL(FILES ${CMAKE_BINARY_DIR}/vmime.pc DESTINATION "${VMIME_INSTALL_LIBDIR}/pkgconfig" COMPONENT headers)
INCLUDE(CPack)
MESSAGE("")
MESSAGE("VMime will install to the following directories:")
MESSAGE(" libraries: ${VMIME_INSTALL_LIBDIR}")
MESSAGE(" headers: ${VMIME_INSTALL_INCLUDEDIR}")
MESSAGE("")