Rework install locations for better flexibility

Using the  CMake module  GNUInstallDirs to  set up  standard locations
which allows  better customisation for packagers  building for various
distributions.

The change does change some internal package file paths and will leave
some  files  in  old   locations  in  Windows  installations.  Running
uninstall  is probably  wise  on Windows  before  installing this  new
package layout if future clean uninstalls are desired.

Linux and other  *nix package maintainers can use  the CMake variables
CMAKE_INSTALL_xxx to vary the install paths of various components. See
the  CMake GNUInstallDirs  module documentation  for more  details. An
example might be for Slackware where package documents are expected to
be                            installed                           into
<install-prefix>/doc/<package-name>-<package-version>/ whereas the GNU
default         is         to        install         them         into
<install-prefix>/share/doc/<package-name>/.  To achieve  this set  the
CMake variable CMAKE_INSTALL_DOCDIR as follows when configuring:

cmake -D CMAKE_INSTALL_DOCDIR:PATH=doc/wsjtx-1.7.1 -D CMAKE_INSTALL_PREFIX= ...

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7623 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2017-03-28 13:03:48 +00:00
parent 38ab140ab6
commit 0e214efb9c
6 changed files with 87 additions and 116 deletions

View File

@ -150,43 +150,27 @@ message (STATUS "******************************************************")
# #
# install locations # install locations
# #
set (BIN_DESTINATION bin)
set (LIB_DESTINATION lib)
set (INCLUDE_DESTINATION include)
set (SHARE_DESTINATION share)
set (DOC_DESTINATION doc/${CMAKE_PROJECT_NAME})
set (DATA_DESTINATION ${CMAKE_PROJECT_NAME})
set (MANPAGE_DESTINATION ${SHARE_DESTINATION})
set (PLUGIN_DESTINATION lib/plugins)
set (QT_CONF_DESTINATION bin)
if (WIN32)
set (SHARE_DESTINATION bin)
set (DOC_DESTINATION doc)
set (DATA_DESTINATION data)
set (PLUGIN_DESTINATION plugins)
endif (WIN32)
if (APPLE) if (APPLE)
set (BIN_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/MacOS) set (CMAKE_INSTALL_BINDIR ${CMAKE_PROJECT_NAME}.app/Contents/MacOS)
set (SHARE_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/Resources) set (CMAKE_INSTALL_DATAROOTDIR ${CMAKE_PROJECT_NAME}.app/Contents/Resources)
set (MANPAGE_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/Resources) endif ()
set (DOC_DESTINATION doc)
set (DATA_DESTINATION data) include (GNUInstallDirs)
set (PLUGIN_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/PlugIns)
set (QT_CONF_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/Resources) set (PLUGIN_DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins)
endif (APPLE) set (QT_CONF_DESTINATION ${CMAKE_INSTALL_BINDIR})
if (WIN32)
set (PLUGIN_DESTINATION plugins)
elseif (APPLE)
set (PLUGIN_DESTINATION ${CMAKE_INSTALL_BINDIR}/../PlugIns)
set (QT_CONF_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
endif ()
set (WSJT_BIN_DESTINATION ${BIN_DESTINATION} CACHE PATH "Path for executables")
set (WSJT_LIB_DESTINATION ${LIB_DESTINATION} CACHE PATH "Path for libraries")
set (WSJT_INCLUDE_DESTINATION ${INCLUDE_DESTINATION} CACHE PATH "Path for library headers")
set (WSJT_SHARE_DESTINATION ${SHARE_DESTINATION} CACHE PATH "Path for shared content")
set (WSJT_DOC_DESTINATION ${DOC_DESTINATION} CACHE PATH "Path for documentation")
set (WSJT_DATA_DESTINATION ${DATA_DESTINATION} CACHE PATH "Path for shared RO data")
set (WSJT_MANPAGE_DESTINATION ${MANPAGE_DESTINATION} CACHE PATH "Path for manpages")
set (WSJT_PLUGIN_DESTINATION ${PLUGIN_DESTINATION} CACHE PATH "Path for plugins") set (WSJT_PLUGIN_DESTINATION ${PLUGIN_DESTINATION} CACHE PATH "Path for plugins")
set (WSJT_QT_CONF_DESTINATION ${QT_CONF_DESTINATION} CACHE PATH "Path for the qt.conf file") set (WSJT_QT_CONF_DESTINATION ${QT_CONF_DESTINATION} CACHE PATH "Path for the qt.conf file")
# #
# Project sources # Project sources
# #
@ -759,6 +743,7 @@ message (STATUS "hamlib_INCLUDE_DIRS: ${hamlib_INCLUDE_DIRS}")
message (STATUS "hamlib_LIBRARIES: ${hamlib_LIBRARIES}") message (STATUS "hamlib_LIBRARIES: ${hamlib_LIBRARIES}")
message (STATUS "hamlib_LIBRARY_DIRS: ${hamlib_LIBRARY_DIRS}") message (STATUS "hamlib_LIBRARY_DIRS: ${hamlib_LIBRARY_DIRS}")
# #
# Qt5 setup # Qt5 setup
# #
@ -899,7 +884,7 @@ set (CMAKE_SKIP_BUILD_RPATH FALSE)
# later on in the install phase # later on in the install phase
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${WSJT_LIB_DESTINATION}") # set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# add the automaticaly determined parts of the RPATH which point to # add the automaticaly determined parts of the RPATH which point to
# directories outside of the build tree to the install RPATH # directories outside of the build tree to the install RPATH
@ -907,9 +892,9 @@ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system # the RPATH to be used when installing, but only if it's not a system
# directory # directory
# list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${WSJT_LIB_DESTINATION}" isSystemDir) # list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
# if ("${isSystemDir}" STREQUAL "-1") # if ("${isSystemDir}" STREQUAL "-1")
# set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${WSJT_LIB_DESTINATION}") # set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# endif ("${isSystemDir}" STREQUAL "-1") # endif ("${isSystemDir}" STREQUAL "-1")
set (QT_NEED_RPATH FALSE) set (QT_NEED_RPATH FALSE)
@ -1186,11 +1171,11 @@ qt5_use_modules (wsjtx SerialPort) # not sure why the interface link library syn
add_library (wsjtx_udp-static STATIC ${UDP_library_CXXSRCS}) add_library (wsjtx_udp-static STATIC ${UDP_library_CXXSRCS})
#target_include_directories (wsjtx_udp #target_include_directories (wsjtx_udp
# INTERFACE # INTERFACE
# $<INSTALL_INTERFACE:${WSJT_INCLUDE_DESTINATION}/wsjtx> # $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsjtx>
# ) # )
target_include_directories (wsjtx_udp-static target_include_directories (wsjtx_udp-static
INTERFACE INTERFACE
$<INSTALL_INTERFACE:${WSJT_INCLUDE_DESTINATION}/wsjtx> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsjtx>
) )
#set_target_properties (wsjtx_udp PROPERTIES #set_target_properties (wsjtx_udp PROPERTIES
# PUBLIC_HEADER "${UDP_library_HEADERS}" # PUBLIC_HEADER "${UDP_library_HEADERS}"
@ -1236,48 +1221,48 @@ endif (UNIX)
# installation # installation
# #
install (TARGETS wsjtx install (TARGETS wsjtx
RUNTIME DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
BUNDLE DESTINATION . COMPONENT runtime BUNDLE DESTINATION . COMPONENT runtime
) )
# install (TARGETS wsjtx_udp EXPORT udp # install (TARGETS wsjtx_udp EXPORT udp
# RUNTIME DESTINATION ${WSJT_BIN_DESTINATION} # RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
# LIBRARY DESTINATION ${WSJT_LIB_DESTINATION} # LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# ARCHIVE DESTINATION ${WSJT_LIB_DESTINATION} # ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${WSJT_INCLUDE_DESTINATION}/wsjtx # PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wsjtx
# ) # )
# install (TARGETS wsjtx_udp-static EXPORT udp-static # install (TARGETS wsjtx_udp-static EXPORT udp-static
# DESTINATION ${WSJT_LIB_DESTINATION} # DESTINATION ${CMAKE_INSTALL_LIBDIR}
# ) # )
# install (EXPORT udp NAMESPACE wsjtx:: # install (EXPORT udp NAMESPACE wsjtx::
# DESTINATION ${WSJT_LIB_DESTINATION}/cmake/wsjtx # DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wsjtx
# ) # )
# install (EXPORT udp-static NAMESPACE wsjtx:: # install (EXPORT udp-static NAMESPACE wsjtx::
# DESTINATION ${WSJT_LIB_DESTINATION}/cmake/wsjtx # DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wsjtx
# ) # )
install (TARGETS udp_daemon message_aggregator install (TARGETS udp_daemon message_aggregator
RUNTIME DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
BUNDLE DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
) )
install (TARGETS jt9 jt65code qra64code qra64sim jt9code jt4code install (TARGETS jt9 jt65code qra64code qra64sim jt9code jt4code
msk144code wsprd fmtave fcal fmeasure msk144code wsprd fmtave fcal fmeasure
RUNTIME DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
BUNDLE DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
) )
install (PROGRAMS install (PROGRAMS
${RIGCTL_EXE} ${RIGCTL_EXE}
DESTINATION ${WSJT_BIN_DESTINATION} DESTINATION ${CMAKE_INSTALL_BINDIR}
#COMPONENT runtime #COMPONENT runtime
RENAME rigctl-wsjtx${CMAKE_EXECUTABLE_SUFFIX} RENAME rigctl-wsjtx${CMAKE_EXECUTABLE_SUFFIX}
) )
install (PROGRAMS install (PROGRAMS
${RIGCTLD_EXE} ${RIGCTLD_EXE}
DESTINATION ${WSJT_BIN_DESTINATION} DESTINATION ${CMAKE_INSTALL_BINDIR}
#COMPONENT runtime #COMPONENT runtime
RENAME rigctld-wsjtx${CMAKE_EXECUTABLE_SUFFIX} RENAME rigctld-wsjtx${CMAKE_EXECUTABLE_SUFFIX}
) )
@ -1290,13 +1275,13 @@ install (FILES
NEWS NEWS
INSTALL INSTALL
BUGS BUGS
DESTINATION ${WSJT_SHARE_DESTINATION}/${WSJT_DOC_DESTINATION} DESTINATION ${CMAKE_INSTALL_DOCDIR}
#COMPONENT runtime #COMPONENT runtime
) )
install (FILES install (FILES
contrib/Ephemeris/JPLEPH contrib/Ephemeris/JPLEPH
DESTINATION ${WSJT_SHARE_DESTINATION}/${WSJT_DATA_DESTINATION} DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}
#COMPONENT runtime #COMPONENT runtime
) )
@ -1395,7 +1380,7 @@ if (NOT is_debug_build)
) )
# if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
set (fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WSJT_BIN_DESTINATION}/${CMAKE_PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") set (fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${CMAKE_PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
#get_filename_component (hamlib_lib_dir ${hamlib_LIBRARIES} PATH) #get_filename_component (hamlib_lib_dir ${hamlib_LIBRARIES} PATH)

View File

@ -731,14 +731,48 @@ void Configuration::sync_transceiver (bool force_signal, bool enforce_mode_and_s
} }
} }
namespace
{
#if defined (Q_OS_MAC)
char const * app_root = "/../../../";
#else
char const * app_root = "/../";
#endif
QString doc_path ()
{
#if CMAKE_BUILD
if (QDir::isRelativePath (CMAKE_INSTALL_DOCDIR))
{
return QApplication::applicationDirPath () + app_root + CMAKE_INSTALL_DOCDIR;
}
return CMAKE_INSTALL_DOCDIR;
#else
return QApplication::applicationDirPath ();
#endif
}
QString data_path ()
{
#if CMAKE_BUILD
if (QDir::isRelativePath (CMAKE_INSTALL_DATADIR))
{
return QApplication::applicationDirPath () + app_root + CMAKE_INSTALL_DATADIR + QChar {'/'} + CMAKE_PROJECT_NAME;
}
return CMAKE_INSTALL_DATADIR;
#else
return QApplication::applicationDirPath ();
#endif
}
}
Configuration::impl::impl (Configuration * self, QDir const& temp_directory, Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
QSettings * settings, QWidget * parent) QSettings * settings, QWidget * parent)
: QDialog {parent} : QDialog {parent}
, self_ {self} , self_ {self}
, ui_ {new Ui::configuration_dialog} , ui_ {new Ui::configuration_dialog}
, settings_ {settings} , settings_ {settings}
, doc_dir_ {QApplication::applicationDirPath ()} , doc_dir_ {doc_path ()}
, data_dir_ {QApplication::applicationDirPath ()} , data_dir_ {data_path ()}
, temp_dir_ {temp_directory} , temp_dir_ {temp_directory}
, frequencies_ {&bands_} , frequencies_ {&bands_}
, next_frequencies_ {&bands_} , next_frequencies_ {&bands_}
@ -763,63 +797,20 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
ui_->setupUi (this); ui_->setupUi (this);
// ui_->groupBox_6->setVisible(false); //### Temporary ??? ### // ui_->groupBox_6->setVisible(false); //### Temporary ??? ###
#if !defined (CMAKE_BUILD)
#define WSJT_SHARE_DESTINATION "."
#define WSJT_DOC_DESTINATION "."
#define WSJT_DATA_DESTINATION "."
#endif
#if !defined (Q_OS_WIN) || QT_VERSION >= 0x050300
auto doc_path = QStandardPaths::locate (QStandardPaths::DataLocation, WSJT_DOC_DESTINATION, QStandardPaths::LocateDirectory);
if (doc_path.isEmpty ())
{
doc_dir_.cdUp ();
#if defined (Q_OS_MAC)
doc_dir_.cdUp ();
doc_dir_.cdUp ();
#endif
doc_dir_.cd (WSJT_SHARE_DESTINATION);
doc_dir_.cd (WSJT_DOC_DESTINATION);
}
else
{
doc_dir_.cd (doc_path);
}
auto data_path = QStandardPaths::locate (QStandardPaths::DataLocation, WSJT_DATA_DESTINATION, QStandardPaths::LocateDirectory);
if (data_path.isEmpty ())
{
data_dir_.cdUp ();
#if defined (Q_OS_MAC)
data_dir_.cdUp ();
data_dir_.cdUp ();
#endif
data_dir_.cd (WSJT_SHARE_DESTINATION);
data_dir_.cd (WSJT_DATA_DESTINATION);
}
else
{
data_dir_.cd (data_path);
}
#else
doc_dir_.cd (WSJT_DOC_DESTINATION);
data_dir_.cd (WSJT_DATA_DESTINATION);
#endif
{ {
// Find a suitable data file location // Find a suitable data file location
QDir data_dir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}; QDir writeable_data_dir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
if (!data_dir.mkpath (".")) if (!writeable_data_dir.mkpath ("."))
{ {
MessageBox::critical_message (this, tr ("Failed to create data directory"), MessageBox::critical_message (this, tr ("Failed to create data directory"),
tr ("path: \"%1\"").arg (data_dir.absolutePath ())); tr ("path: \"%1\"").arg (writeable_data_dir.absolutePath ()));
throw std::runtime_error {"Failed to create data directory"}; throw std::runtime_error {"Failed to create data directory"};
} }
// Make sure the default save directory exists // Make sure the default save directory exists
QString save_dir {"save"}; QString save_dir {"save"};
default_save_directory_ = data_dir; default_save_directory_ = writeable_data_dir;
default_azel_directory_ = data_dir; default_azel_directory_ = writeable_data_dir;
if (!default_save_directory_.mkpath (save_dir) || !default_save_directory_.cd (save_dir)) if (!default_save_directory_.mkpath (save_dir) || !default_save_directory_.cd (save_dir))
{ {
MessageBox::critical_message (this, tr ("Failed to create save directory"), MessageBox::critical_message (this, tr ("Failed to create save directory"),

View File

@ -34,6 +34,6 @@ configure_file (
install (FILES install (FILES
${CMAKE_CURRENT_BINARY_DIR}/${deb_changelog}.gz ${CMAKE_CURRENT_BINARY_DIR}/${deb_changelog}.gz
${CMAKE_CURRENT_BINARY_DIR}/copyright ${CMAKE_CURRENT_BINARY_DIR}/copyright
DESTINATION ${WSJT_SHARE_DESTINATION}/${WSJT_DOC_DESTINATION} DESTINATION ${CMAKE_INSTALL_DOCDIR}
#COMPONENT Debian #COMPONENT Debian
) )

View File

@ -223,7 +223,7 @@ foreach (_html ${htmls})
string (REGEX REPLACE "_en$" "" _nwe ${_nwe}) string (REGEX REPLACE "_en$" "" _nwe ${_nwe})
install (FILES install (FILES
${_html} ${_html}
DESTINATION ${WSJT_SHARE_DESTINATION}/${WSJT_DOC_DESTINATION} DESTINATION ${CMAKE_INSTALL_DOCDIR}
RENAME ${_nwe}-${wsjtx_VERSION}${_ext} RENAME ${_nwe}-${wsjtx_VERSION}${_ext}
#COMPONENT runtime #COMPONENT runtime
) )

View File

@ -75,8 +75,8 @@ if (A2X_EXECUTABLE AND GZIP_EXECUTABLE AND SED_EXECUTABLE)
endforeach () endforeach ()
install ( install (
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man/
DESTINATION ${WSJT_MANPAGE_DESTINATION} DESTINATION ${CMAKE_INSTALL_MANDIR}
PATTERN "*.orig" EXCLUDE PATTERN "*.orig" EXCLUDE
#COMPONENT Runtime #COMPONENT Runtime
) )

View File

@ -5,15 +5,10 @@
#define WSJTX_VERSION_MINOR @WSJTX_VERSION_MINOR@ #define WSJTX_VERSION_MINOR @WSJTX_VERSION_MINOR@
#define WSJTX_VERSION_PATCH @WSJTX_VERSION_PATCH@ #define WSJTX_VERSION_PATCH @WSJTX_VERSION_PATCH@
#define CONFIG_TEST_VERSION_MAJOR @CONFIG_TEST_VERSION_MAJOR@ #cmakedefine CMAKE_INSTALL_DATAROOTDIR "@CMAKE_INSTALL_DATAROOTDIR@"
#define CONFIG_TEST_VERSION_MINOR @CONFIG_TEST_VERSION_MINOR@ #cmakedefine CMAKE_INSTALL_DOCDIR "@CMAKE_INSTALL_DOCDIR@"
#define CONFIG_TEST_VERSION_PATCH @CONFIG_TEST_VERSION_PATCH@ #cmakedefine CMAKE_INSTALL_DATADIR "@CMAKE_INSTALL_DATADIR@"
#cmakedefine CMAKE_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#cmakedefine WSJT_BIN_DESTINATION "@WSJT_BIN_DESTINATION@"
#cmakedefine WSJT_SHARE_DESTINATION "@WSJT_SHARE_DESTINATION@"
#cmakedefine WSJT_LIB_DESTINATION "@WSJT_LIB_DESTINATION@"
#cmakedefine WSJT_DOC_DESTINATION "@WSJT_DOC_DESTINATION@"
#cmakedefine WSJT_DATA_DESTINATION "@WSJT_DATA_DESTINATION@"
#cmakedefine PROJECT_MANUAL "@PROJECT_MANUAL@" #cmakedefine PROJECT_MANUAL "@PROJECT_MANUAL@"
#cmakedefine PROJECT_HOMEPAGE "@PROJECT_HOMEPAGE@" #cmakedefine PROJECT_HOMEPAGE "@PROJECT_HOMEPAGE@"
#cmakedefine PROJECT_MANUAL_DIRECTORY_URL "@PROJECT_MANUAL_DIRECTORY_URL@" #cmakedefine PROJECT_MANUAL_DIRECTORY_URL "@PROJECT_MANUAL_DIRECTORY_URL@"