Skip to content

Commit

Permalink
Qt "qt.conf" file used for installation phase and some build code cle…
Browse files Browse the repository at this point in the history
…anup made.
  • Loading branch information
schetnikovich committed Jan 20, 2016
1 parent 8178aa9 commit 20301dd
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 196 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ include(PrintUtils)
include(DefineCMakeDefaults)
include(DefineDefaults)
include(DefineTrashSymbols)
include(QtInstall)
include(PackageRobomongo)
include(QtConf)

# Search for dependencies
find_package(Threads REQUIRED)
Expand Down
166 changes: 40 additions & 126 deletions cmake/InstallRobomongo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,144 +14,52 @@ set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install"
CACHE STRING "Install path prefix, prepended onto install directories"
FORCE)

set(install_dir ${CMAKE_INSTALL_PREFIX})

if(SYSTEM_LINUX)
set(bin_dir bin)
set(lib_dir lib)
set(qt_plugin_dir ${lib_dir})
set(resources_dir share)
set(license_dir .)
set(bin_dir bin)
set(lib_dir lib)
set(resources_dir share)
set(license_dir .)

set(qt_plugins_dir ${lib_dir})
set(qt_conf_dir ${bin_dir})
set(qt_conf_plugins "../lib")
elseif(SYSTEM_MACOSX)
set(bundle_name Robomongo.app)
set(contents_path ${bundle_name}/Contents)
set(bundle_name Robomongo.app)
set(contents_path ${bundle_name}/Contents)

set(bin_dir ${contents_path}/MacOS)
set(lib_dir ${contents_path}/Frameworks)
set(resources_dir ${contents_path}/Resources)
set(license_dir ${resources_dir})

set(bin_dir ${contents_path}/MacOS)
set(lib_dir ${contents_path}/Frameworks)
set(qt_plugin_dir ${contents_path}/PlugIns/Qt)
set(resources_dir ${contents_path}/Resources)
set(license_dir ${resources_dir})
set(qt_plugins_dir ${contents_path}/PlugIns/Qt)
set(qt_conf_dir ${resources_dir})
set(qt_conf_plugins "PlugIns/Qt")
endif()

# Generate qt.conf file
configure_file(
"${CMAKE_SOURCE_DIR}/install/qt.conf.in"
"${CMAKE_BINARY_DIR}/qt.conf")

# Install qt.conf file
install(
FILES "${CMAKE_BINARY_DIR}/qt.conf"
DESTINATION "${qt_conf_dir}")

# Install binary
install(
TARGETS robomongo
RUNTIME DESTINATION ${bin_dir}
BUNDLE DESTINATION .)

# Install license, copyright and changelogs files
install(
FILES
${CMAKE_SOURCE_DIR}/LICENSE
${CMAKE_SOURCE_DIR}/COPYRIGHT
${CMAKE_SOURCE_DIR}/CHANGELOG
DESTINATION
${license_dir})

if(SYSTEM_MACOSX)
install(
FILES
"${CMAKE_SOURCE_DIR}/install/macosx/Robomongo.icns"
DESTINATION
${resources_dir})
endif()

function(install_qt_lib)
foreach(module ${ARGV})
set(target_name Qt5::${module})

# Get full path to some known Qt library (i.e. /path/to/lib/libQt5Widgets.so.5.5.1)
get_target_property(target_path Qt5::Core LOCATION)

# Get folder path of library (i.e. /path/to/lib)
get_filename_component(qt_lib_dir ${target_path} DIRECTORY)

if (SYSTEM_LINUX)
set(module_name Qt5${module})

# Not very good solution, but we simply take all files with *Qt5<module>* in names (including symlinks)
file(GLOB module_libs ${qt_lib_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}${module_name}*)

# Install to "lib" folder
install(FILES ${module_libs}
DESTINATION ${lib_dir})
endif()

if(SYSTEM_MACOSX)
set(module_name Qt${module})

# On Mac OS we are still located in .framework folder,
# and we need to go one level up
get_filename_component(qt_lib_dir ${qt_lib_dir} DIRECTORY)

install(
DIRECTORY ${qt_lib_dir}/${module_name}.framework
DESTINATION ${lib_dir}
PATTERN "*_debug" EXCLUDE # Exclude debug libraries
PATTERN "Headers" EXCLUDE) # Exclude Headers folders
endif()

endforeach()
endfunction()

function(install_icu_libs)
# We are trying to get 'lib' folder of Qt installation.
# For this we take some known target (Qt5::Core in this case)
# and taking path to this library.

# Get full path to known library (i.e. /path/to/lib/libQt5Core.so.5.5.1)
get_target_property(target_path Qt5::Core LOCATION)

# Get absolute path to 'lib' folder (which is a parent folder of 'known' library)
get_filename_component(qt_lib_dir ${target_path} DIRECTORY)

# Not very good solution, but we simply take all files with *icu* in names (including symlinks)
file(GLOB icu_libs ${qt_lib_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}icu*)

# Install to "lib" folder
install(FILES ${icu_libs}
DESTINATION ${lib_dir})
endfunction()

# Installs Qt5 plugins.
#
# You can find list of plugin names by examing this variable: Qt5<Module>_PLUGINS
# For example, Qt5Gui_PLUGINS.
#
# Debug plugins, running application in this way:
# QT_DEBUG_PLUGINS=1 ./yourapp
#
# Some examples of plugin names:
# QGifPlugin, QGtk2ThemePlugin, QIbusPlatformInputContextPlugin
#
# Sample:
# install_qt_plugins(QGifPlugin QGtk2ThemePlugin QIbusPlatformInputContextPlugin)
#
function(install_qt_plugins)
foreach(name ${ARGV})
set(target_name Qt5::${name})

# We are trying to get 'plugins' folder of Qt installation.

# Get full path to plugin library (i.e. /path/to/plugins/imageformats/libqgif.so)
get_target_property(target_path ${target_name} LOCATION)

# Get absolute path to parent folder (i.e. /path/to/plugins/imageformats for Qt5::QGifPlugin)
get_filename_component(plugin_dir ${target_path} DIRECTORY)

# Get plugin parent directory (i.e. "imageformats" for Qt5::QGifPlugin)
get_filename_component(plugin_dir_name ${plugin_dir} NAME)

# Get plugin file name (i.e. "libqgif.so" for Qt5::QGifPlugin)
get_filename_component(plugin_file_name ${target_path} NAME)

# Get absolute path to plugins folder (i.e. /path/to/plugins)
get_filename_component(plugins_dir ${plugin_dir} DIRECTORY)

# Install to "lib" folder
install(
FILES ${target_path}
DESTINATION ${qt_plugin_dir}/${plugin_dir_name})
endforeach()
endfunction()
DESTINATION ${license_dir})

# Install common dependencies
install_qt_lib(Core Gui Widgets PrintSupport)
Expand All @@ -160,14 +68,20 @@ install_icu_libs()

if(SYSTEM_LINUX)
install_qt_lib(XcbQpa DBus)
install_qt_plugins(QGtk2ThemePlugin QXcbIntegrationPlugin)
endif()
install_qt_plugins(
QGtk2ThemePlugin
QXcbIntegrationPlugin)

if(SYSTEM_MACOSX)
elseif(SYSTEM_MACOSX)
install_qt_lib(MacExtras DBus)
install_qt_plugins(
QCocoaIntegrationPlugin
QMinimalIntegrationPlugin
QOffscreenIntegrationPlugin)

# Install icon
install(
FILES "${CMAKE_SOURCE_DIR}/install/macosx/Robomongo.icns"
DESTINATION "${resources_dir}")
endif()

15 changes: 0 additions & 15 deletions cmake/QtConf.cmake

This file was deleted.

100 changes: 100 additions & 0 deletions cmake/QtInstall.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
function(install_qt_lib)
foreach(module ${ARGV})
set(target_name Qt5::${module})

# Get full path to some known Qt library (i.e. /path/to/lib/libQt5Widgets.so.5.5.1)
get_target_property(target_path Qt5::Core LOCATION)

# Get folder path of library (i.e. /path/to/lib)
get_filename_component(qt_lib_dir ${target_path} DIRECTORY)

if (SYSTEM_LINUX)
set(module_name Qt5${module})

# Not very good solution, but we simply take all files with *Qt5<module>* in names (including symlinks)
file(GLOB module_libs ${qt_lib_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}${module_name}*)

# Install to "lib" folder
install(FILES ${module_libs}
DESTINATION ${lib_dir})
endif()

if(SYSTEM_MACOSX)
set(module_name Qt${module})

# On Mac OS we are still located in .framework folder,
# and we need to go one level up
get_filename_component(qt_lib_dir ${qt_lib_dir} DIRECTORY)

install(
DIRECTORY ${qt_lib_dir}/${module_name}.framework
DESTINATION ${lib_dir}
PATTERN "*_debug" EXCLUDE # Exclude debug libraries
PATTERN "Headers" EXCLUDE) # Exclude Headers folders
endif()

endforeach()
endfunction()

function(install_icu_libs)
# We are trying to get 'lib' folder of Qt installation.
# For this we take some known target (Qt5::Core in this case)
# and taking path to this library.

# Get full path to known library (i.e. /path/to/lib/libQt5Core.so.5.5.1)
get_target_property(target_path Qt5::Core LOCATION)

# Get absolute path to 'lib' folder (which is a parent folder of 'known' library)
get_filename_component(qt_lib_dir ${target_path} DIRECTORY)

# Not very good solution, but we simply take all files with *icu* in names (including symlinks)
file(GLOB icu_libs ${qt_lib_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}icu*)

# Install to "lib" folder
install(FILES ${icu_libs}
DESTINATION ${lib_dir})
endfunction()

# Installs Qt5 plugins. Uses value of global variable "qt_plugins_dir" as
# absolute path to where install plugins.
#
# You can find list of plugin names by examing this variable: Qt5<Module>_PLUGINS
# For example, Qt5Gui_PLUGINS.
#
# Debug plugins, running application in this way:
# QT_DEBUG_PLUGINS=1 ./yourapp
#
# Some examples of plugin names:
# QGifPlugin, QGtk2ThemePlugin, QIbusPlatformInputContextPlugin
#
# Sample:
# install_qt_plugins(QGifPlugin QGtk2ThemePlugin QIbusPlatformInputContextPlugin)
#
function(install_qt_plugins)
foreach(name ${ARGV})
set(target_name Qt5::${name})

# We are trying to get 'plugins' folder of Qt installation.

# Get full path to plugin library (i.e. /path/to/plugins/imageformats/libqgif.so)
get_target_property(target_path ${target_name} LOCATION)

# Get absolute path to parent folder (i.e. /path/to/plugins/imageformats for Qt5::QGifPlugin)
get_filename_component(plugin_dir ${target_path} DIRECTORY)

# Get plugin parent directory (i.e. "imageformats" for Qt5::QGifPlugin)
get_filename_component(plugin_dir_name ${plugin_dir} NAME)

# Get plugin file name (i.e. "libqgif.so" for Qt5::QGifPlugin)
get_filename_component(plugin_file_name ${target_path} NAME)

# Get absolute path to plugins folder (i.e. /path/to/plugins)
get_filename_component(plugins_dir ${plugin_dir} DIRECTORY)

# Install to "lib" folder
install(
FILES ${target_path}
DESTINATION ${qt_plugins_dir}/${plugin_dir_name})
endforeach()
endfunction()

2 changes: 2 additions & 0 deletions install/qt.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Paths]
Plugins = @qt_conf_plugins@
Loading

0 comments on commit 20301dd

Please sign in to comment.