Skip to content

Commit

Permalink
Merge pull request #190 from remicollet/issue-gnuinstalldirs
Browse files Browse the repository at this point in the history
restore GNUInstallDirs
  • Loading branch information
0-wiz-0 authored Jul 13, 2020
2 parents f520e28 + ebe01b5 commit 60a6bf3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ include(CheckCSourceRuns)
include(CheckCSourceCompiles)
include(CheckStructHasMember)
include(TestBigEndian)
include(GNUInstallDirs)
if(ENABLE_COMMONCRYPTO)
check_include_files(CommonCrypto/CommonCrypto.h COMMONCRYPTO_FOUND)
else()
Expand Down Expand Up @@ -237,7 +238,7 @@ endif(WIN32)

# rpath handling: use rpath in installed binaries
if(NOT CMAKE_SYSTEM_NAME MATCHES Linux)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

Expand Down Expand Up @@ -282,9 +283,9 @@ endif()
# pkgconfig file
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix \${prefix})
set(bindir \${exec_prefix}/bin)
set(libdir \${exec_prefix}/lib)
set(includedir \${prefix}/include)
SET(bindir \${exec_prefix}/${CMAKE_INSTALL_BINDIR})
SET(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
SET(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
if(CMAKE_SYSTEM_NAME MATCHES BSD)
set(PKG_CONFIG_RPATH "-Wl,-R\${libdir}")
endif(CMAKE_SYSTEM_NAME MATCHES BSD)
Expand All @@ -304,7 +305,7 @@ string(REGEX REPLACE "-lGnuTLS::GnuTLS" "-lgnutls" LIBS ${LIBS})
string(REGEX REPLACE "-lNettle::Nettle" "-lnettle" LIBS ${LIBS})
configure_file(libzip.pc.in libzip.pc @ONLY)
if(LIBZIP_DO_INSTALL)
install(FILES ${PROJECT_BINARY_DIR}/libzip.pc DESTINATION lib/pkgconfig)
install(FILES ${PROJECT_BINARY_DIR}/libzip.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()

# fixed size integral types
Expand Down Expand Up @@ -426,7 +427,7 @@ write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-v
COMPATIBILITY AnyNewerVersion)

configure_package_config_file("${PROJECT_NAME}-config.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION lib/cmake/libzip)
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libzip)

# Add targets to the build-tree export set
export(TARGETS zip
Expand All @@ -436,10 +437,10 @@ export(TARGETS zip
if(LIBZIP_DO_INSTALL)
install(FILES ${PROJECT_BINARY_DIR}/zipconf.h DESTINATION include)
install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION lib/cmake/${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(EXPORT ${PROJECT_NAME}-targets NAMESPACE libzip:: FILE ${PROJECT_NAME}-targets.cmake
DESTINATION lib/cmake/${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
endif()

10 changes: 5 additions & 5 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ target_include_directories(zip
if(LIBZIP_DO_INSTALL)
install(TARGETS zip
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
LIBRARY DESTINATION lib)
install(FILES zip.h DESTINATION include)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES zip.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()

# create zip_err_str.h from zip.h
Expand Down
8 changes: 4 additions & 4 deletions man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ foreach(MAN_PAGE ${MAN_PAGES})
string(REGEX REPLACE "[1-9]$" "${DOCUMENTATION_FORMAT}" SOURCE_FILE ${MAN_PAGE})
if(LIBZIP_DO_INSTALL)
if (DOCUMENTATION_FORMAT MATCHES "html")
install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION share/doc/${PROJECT_NAME} RENAME ${SOURCE_FILE})
install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME} RENAME ${SOURCE_FILE})
else()
string(REGEX REPLACE ".*(.)$" "man\\1" SUBDIR ${MAN_PAGE})
install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION man/${SUBDIR})
install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION ${CMAKE_INSTALL_MANDIR}/${SUBDIR})
endif()
endif()
# configure_file does not find out about updates to the sources, and it does not provide a target
Expand Down Expand Up @@ -147,9 +147,9 @@ foreach(LINKS_LINE ${MANPAGE_LINKS})
set(TARGET ${CMAKE_MATCH_2})
if(LIBZIP_DO_INSTALL)
if (DOCUMENTATION_FORMAT MATCHES "html")
INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION share/doc/${PROJECT_NAME} RENAME ${TARGET}.html)
INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME} RENAME ${TARGET}.html)
else()
INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION man/man3 RENAME ${TARGET}.3)
INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 RENAME ${TARGET}.3)
endif()
endif()
endif()
Expand Down

0 comments on commit 60a6bf3

Please sign in to comment.