Permalink
Browse files

Issue #175: use CMake macros for installation dir.

  • Loading branch information...
vincent-richard committed Jun 19, 2017
1 parent 50b312f commit 3d3ed7b26003bce0b2ce7aa355e46da4894fce39
Showing with 9 additions and 43 deletions.
  1. +9 −43 CMakeLists.txt
View
@@ -23,6 +23,7 @@ INCLUDE(CheckSymbolExists)
INCLUDE(CheckTypeSize)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(GNUInstallDirs)
# CMake configuration
@@ -194,55 +195,20 @@ ENDIF()
SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
# Automatically set lib suffix
IF(UNIX AND NOT APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/debian_version")
IF(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT LIB_SUFFIX)
# ...only if LIB_SUFFIX is not defined...
IF(NOT DEFINED LIB_SUFFIX)
# ...and if CMAKE_INSTALL_LIBDIR does not already contain the suffix
IF(NOT "${CMAKE_INSTALL_LIBDIR}" MATCHES ".*64.*")
SET(LIB_SUFFIX 64)
ENDIF()
ENDIF()
ENDIF()
ENDIF()
# Determine library installation dir, in this order:
# 1) use VMIME_INSTALL_LIBDIR if set
# 2) use LIB_INSTALL_DIR if defined
# 3) use CMAKE_INSTALL_LIBDIR if set
# if it is a relative path, prepend CMAKE_INSTALL_PREFIX to it
# 4) use CMAKE_INSTALL_PREFIX/lib
IF(NOT DEFINED VMIME_INSTALL_LIBDIR)
IF(DEFINED LIB_INSTALL_DIR)
SET(VMIME_INSTALL_LIBDIR ${LIB_INSTALL_DIR})
# respect CMAKE_INSTALL_LIBDIR if set
ELSEIF(DEFINED CMAKE_INSTALL_LIBDIR)
SET(VMIME_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
IF(IS_ABSOLUTE ${VMIME_INSTALL_LIBDIR})
SET(VMIME_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX})
ELSE()
SET(VMIME_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX})
ENDIF()
ELSE()
SET(VMIME_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
ENDIF()
ENDIF()
# Installation of libraries
IF(VMIME_BUILD_SHARED_LIBRARY)
INSTALL(
TARGETS ${VMIME_LIBRARY_NAME}
LIBRARY DESTINATION "${VMIME_INSTALL_LIBDIR}" COMPONENT sharedlibs
ARCHIVE DESTINATION "${VMIME_INSTALL_LIBDIR}" COMPONENT sharedlibs
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT sharedlibs
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT sharedlibs
)
ENDIF()
IF(VMIME_BUILD_STATIC_LIBRARY)
INSTALL(
TARGETS ${VMIME_LIBRARY_NAME}-static
LIBRARY DESTINATION "${VMIME_INSTALL_LIBDIR}" COMPONENT staticlibs
ARCHIVE DESTINATION "${VMIME_INSTALL_LIBDIR}" COMPONENT staticlibs
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT staticlibs
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT staticlibs
)
ENDIF()
@@ -411,9 +377,9 @@ ADD_CUSTOM_TARGET(
# PkgConfig
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
SET(includedir ${CMAKE_INSTALL_PREFIX}/include/vmime)
SET(libdir ${VMIME_INSTALL_LIBDIR})
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(VMIME_PKGCONFIG_LIBS "")
SET(VMIME_PKGCONFIG_CFLAGS "")
@@ -1118,7 +1084,7 @@ CONFIGURE_FILE(cmake/config.hpp.cmake ${CMAKE_BINARY_DIR}/src/vmime/config.hpp)
# PkgConfig post-configuration
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/vmime.pc.in ${CMAKE_BINARY_DIR}/vmime.pc @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/vmime.pc DESTINATION "${VMIME_INSTALL_LIBDIR}/pkgconfig" COMPONENT headers)
INSTALL(FILES ${CMAKE_BINARY_DIR}/vmime.pc DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT headers)
INCLUDE(CPack)

0 comments on commit 3d3ed7b

Please sign in to comment.