Use CMAKE_INSTALL_* variables when installing in CMake.

Closes #1049. Thanks to Greg Troxel.
This commit is contained in:
Roger A. Light 2019-04-26 15:51:48 +01:00
parent efa649f451
commit 439575475c
7 changed files with 23 additions and 45 deletions

View File

@ -16,35 +16,12 @@ set (VERSION 1.6.0)
add_definitions (-DCMAKE -DVERSION=\"${VERSION}\") add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")
if (WIN32) if (WIN32)
set (BINDIR .)
set (SBINDIR .)
set (SYSCONFDIR .)
set (LIBDIR .)
set (INCLUDEDIR include)
set (DATAROOTDIR share)
set (MANDIR man)
set (SHAREDEST .)
set (PKGCONFIGDIR "${LIBDIR}/pkgconfig")
add_definitions("-D_CRT_SECURE_NO_WARNINGS") add_definitions("-D_CRT_SECURE_NO_WARNINGS")
add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE") add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE")
else (WIN32)
set (BINDIR bin)
set (SBINDIR sbin)
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL /usr)
set (SYSCONFDIR /etc/mosquitto)
else ("${CMAKE_INSTALL_PREFIX}" STREQUAL /usr)
set (SYSCONFDIR etc/mosquitto)
endif ("${CMAKE_INSTALL_PREFIX}" STREQUAL /usr)
set (LIBDIR lib${LIB_SUFFIX})
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
set (INCLUDEDIR include)
set (DATAROOTDIR share)
set (MANDIR "${DATAROOTDIR}/man")
set (SHAREDIR "${DATAROOTDIR}/mosquitto")
set (PKGCONFIGDIR "${LIBDIR}/pkgconfig")
endif (WIN32) endif (WIN32)
include(GNUInstallDirs)
option(WITH_TLS option(WITH_TLS
"Include SSL/TLS support?" ON) "Include SSL/TLS support?" ON)
option(WITH_TLS_PSK option(WITH_TLS_PSK
@ -123,7 +100,7 @@ endif (DOCUMENTATION)
# Install config file # Install config file
# ======================================== # ========================================
install(FILES mosquitto.conf aclfile.example pskfile.example pwfile.example DESTINATION "${SYSCONFDIR}") install(FILES mosquitto.conf aclfile.example pskfile.example pwfile.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto")
# ======================================== # ========================================
@ -131,9 +108,9 @@ install(FILES mosquitto.conf aclfile.example pskfile.example pwfile.example DEST
# ======================================== # ========================================
configure_file(libmosquitto.pc.in libmosquitto.pc @ONLY) configure_file(libmosquitto.pc.in libmosquitto.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquitto.pc" DESTINATION "${PKGCONFIGDIR}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquitto.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pkgconfig")
configure_file(libmosquittopp.pc.in libmosquittopp.pc @ONLY) configure_file(libmosquittopp.pc.in libmosquittopp.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquittopp.pc" DESTINATION "${PKGCONFIGDIR}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquittopp.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pkgconfig")
# ======================================== # ========================================
# Testing # Testing

View File

@ -13,6 +13,7 @@ Build:
- Split CFLAGS and CPPFLAGS, and LDFLAGS and LDADD/LIBADD. - Split CFLAGS and CPPFLAGS, and LDFLAGS and LDADD/LIBADD.
- test/unit now respects CPPFLAGS and LDFLAGS. Closes #1232. - test/unit now respects CPPFLAGS and LDFLAGS. Closes #1232.
- Don't call ldconfig in CMake scripts. Closes #1048. - Don't call ldconfig in CMake scripts. Closes #1048.
- Use CMAKE_INSTALL_* variables when installing in CMake. Closes #1049.
1.6 - 20190417 1.6 - 20190417

View File

@ -24,6 +24,6 @@ if (QNX)
target_link_libraries(mosquitto_rr socket) target_link_libraries(mosquitto_rr socket)
endif() endif()
install(TARGETS mosquitto_pub RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS mosquitto_pub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS mosquitto_sub RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS mosquitto_sub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS mosquitto_rr RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS mosquitto_rr RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

View File

@ -89,7 +89,7 @@ set_target_properties(libmosquitto PROPERTIES
SOVERSION 1 SOVERSION 1
) )
install(TARGETS libmosquitto RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS libmosquitto LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
if (WITH_STATIC_LIBRARIES) if (WITH_STATIC_LIBRARIES)
add_library(libmosquitto_static STATIC ${C_SRC}) add_library(libmosquitto_static STATIC ${C_SRC})
@ -107,7 +107,7 @@ if (WITH_STATIC_LIBRARIES)
) )
target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC") target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS libmosquitto_static RUNTIME DESTINATION "${BINDIR}" ARCHIVE DESTINATION "${LIBDIR}") install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif (WITH_STATIC_LIBRARIES) endif (WITH_STATIC_LIBRARIES)
install(FILES mosquitto.h DESTINATION "${INCLUDEDIR}") install(FILES mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

View File

@ -13,7 +13,7 @@ set_target_properties(mosquittopp PROPERTIES
VERSION ${VERSION} VERSION ${VERSION}
SOVERSION 1 SOVERSION 1
) )
install(TARGETS mosquittopp RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS mosquittopp LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
if (WITH_STATIC_LIBRARIES) if (WITH_STATIC_LIBRARIES)
add_library(mosquittopp_static STATIC add_library(mosquittopp_static STATIC
@ -34,7 +34,7 @@ if (WITH_STATIC_LIBRARIES)
) )
target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC") target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS mosquittopp_static RUNTIME DESTINATION "${BINDIR}" ARCHIVE DESTINATION "${LIBDIR}") install(TARGETS mosquittopp_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif (WITH_STATIC_LIBRARIES) endif (WITH_STATIC_LIBRARIES)
install(FILES mosquittopp.h DESTINATION "${INCLUDEDIR}") install(FILES mosquittopp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

View File

@ -1,5 +1,5 @@
install(FILES mosquitto_passwd.1 mosquitto_pub.1 mosquitto_sub.1 mosquitto_rr.1 DESTINATION ${MANDIR}/man1) install(FILES mosquitto_passwd.1 mosquitto_pub.1 mosquitto_sub.1 mosquitto_rr.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES libmosquitto.3 DESTINATION ${MANDIR}/man3) install(FILES libmosquitto.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
install(FILES mosquitto.conf.5 DESTINATION ${MANDIR}/man5) install(FILES mosquitto.conf.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5)
install(FILES mosquitto-tls.7 mqtt.7 DESTINATION ${MANDIR}/man7) install(FILES mosquitto-tls.7 mqtt.7 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7)
install(FILES mosquitto.8 DESTINATION ${MANDIR}/man8) install(FILES mosquitto.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)

View File

@ -184,11 +184,11 @@ if (UNIX)
endif (APPLE) endif (APPLE)
endif (UNIX) endif (UNIX)
install(TARGETS mosquitto RUNTIME DESTINATION "${SBINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS mosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_SBINDIR}")
install(FILES mosquitto_broker.h mosquitto_plugin.h DESTINATION "${INCLUDEDIR}") install(FILES mosquitto_broker.h mosquitto_plugin.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
if (WITH_TLS) if (WITH_TLS)
add_executable(mosquitto_passwd mosquitto_passwd.c) add_executable(mosquitto_passwd mosquitto_passwd.c)
target_link_libraries(mosquitto_passwd ${OPENSSL_LIBRARIES}) target_link_libraries(mosquitto_passwd ${OPENSSL_LIBRARIES})
install(TARGETS mosquitto_passwd RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}") install(TARGETS mosquitto_passwd RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif (WITH_TLS) endif (WITH_TLS)