Mercurial > irccd
changeset 270:90909cf677b1
CMake: make installation of DLLs more generic
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 19 Sep 2016 13:42:54 +0200 |
parents | 08a041011599 |
children | 3d37e1afec54 |
files | CMakeLists.txt cmake/function/IrccdIndentMessage.cmake win32/CMakeLists.txt |
diffstat | 3 files changed, 106 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Sun Sep 18 11:16:09 2016 +0200 +++ b/CMakeLists.txt Mon Sep 19 13:42:54 2016 +0200 @@ -65,6 +65,7 @@ include(cmake/function/IrccdDefineMan.cmake) include(cmake/function/IrccdDefinePlugin.cmake) include(cmake/function/IrccdDefineTest.cmake) +include(cmake/function/IrccdIndentMessage.cmake) include(cmake/check/PutTime.cmake) @@ -112,22 +113,25 @@ message("Installing plugins:") foreach (plugin ${IRCCD_PLUGINS}) string(TOUPPER ${plugin} name) - string(LENGTH ${plugin} length) - set(str " ${plugin}:") + irccd_indent_message(" ${plugin}: " "${WITH_PLUGIN_${name}_MSG}" 22) +endforeach () +message("") - # - # Build a string to indent the output correctly because tabs do not work well in all windows - # (e.g. CMake's GUI, QtCreator...) - # - while (${length} LESS 17) - math(EXPR length "${length} + 1") - set(str "${str} ") - endwhile () +if (WIN32) + message("Installing these DLLs:") + foreach (name ${IRCCD_DLLS}) + irccd_indent_message(" ${name}: " "${${name}}" 30) + endforeach () + message("") - message("${str}${WITH_PLUGIN_${name}_MSG}") -endforeach () - -message("") + if (IRCCD_DLLS_NOT_FOUND) + message("The following DLLs were not found:") + foreach (name ${IRCCD_DLLS_NOT_FOUND}) + message(" ${name}") + endforeach () + message("") + endif () +endif () include(cmake/IrccdPackage.cmake) include(CPack)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake/function/IrccdIndentMessage.cmake Mon Sep 19 13:42:54 2016 +0200 @@ -0,0 +1,46 @@ +# +# IrccdIndentMessage.cmake -- CMake build system for irccd +# +# Copyright (c) 2016 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +# +# irccd_indent_message +# ------------------------------------------------------------------- +# +# irccd_indent_message(variable value padding) +# +# Indent a message and its value with the specified amount of spaces between +# variable and value. +# +# Example: +# +# irccd_indent_message("godmode: " "false", 20) +# +# Will output: +# +# godmode: false +# + +function(irccd_indent_message var value padding) + string(LENGTH "${var}" length) + + while (${length} LESS ${padding}) + math(EXPR length "${length} + 1") + set(space "${space} ") + endwhile () + + message("${var}${space}${value}") +endfunction()
--- a/win32/CMakeLists.txt Sun Sep 18 11:16:09 2016 +0200 +++ b/win32/CMakeLists.txt Mon Sep 19 13:42:54 2016 +0200 @@ -31,33 +31,14 @@ if (MINGW) if (IRCCD_64BITS) - find_program(LIBGCC_DLL libgcc_s_seh-1.dll) + set(LIBGCC_DLL libgcc_s_seh-1.dll) else () - find_program(LIBGCC_DLL libgcc_s_sjlj-1.dll) + set(LIBGCC_DLL libgcc_s_sjlj-1.dll) endif () - find_program(LIBWINPTHREAD_DLL libwinpthread-1.dll) - find_program(LIBSTDCPP_DLL libstdc++-6.dll) - - set(WITH_LIBGCC_DLL "${LIBGCC_DLL}" CACHE STRING - "Path to libgcc dll") - set(WITH_LIBWINPTHREAD_DLL "${LIBWINPTHREAD_DLL}" CACHE STRING - "Path to libwinpthread dll") - set(WITH_LIBSTDCPP_DLL "${LIBSTDCPP_DLL}" CACHE STRING - "Path to libstdc++ dll") - - if (EXISTS ${WITH_LIBGCC_DLL} AND - EXISTS ${WITH_LIBWINPTHREAD_DLL} AND - EXISTS ${WITH_LIBSTDCPP_DLL}) - install( - PROGRAMS - ${WITH_LIBGCC_DLL} - ${WITH_LIBWINPTHREAD_DLL} - ${WITH_LIBSTDCPP_DLL} - COMPONENT libirccd - DESTINATION bin - ) - endif () + set(LIBWINPTHREAD_DLL libwinpthread-1.dll) + set(LIBSTDCPP_DLL libstdc++-6.dll) + list(APPEND DLLS LIBGCC_DLL LIBWINPTHREAD_DLL LIBSTDCPP_DLL) endif () # @@ -66,21 +47,47 @@ # if (WITH_SSL) - find_program(SSL_EAY_DLL libeay32.dll) - find_program(SSL_LIB_DLL ssleay32.dll) + set(SSL_EAY_DLL libeay32.dll) + set(SSL_LIB_DLL ssleay32.dll) + list(APPEND DLLS SSL_EAY_DLL SSL_LIB_DLL) +endif () - set(WITH_SSL_EAY_DLL "${SSL_EAY_DLL}" CACHE STRING - "Path to ssleay32.dll") - set(WITH_SSL_LIB_DLL "${SSL_LIB_DLL}" CACHE STRING - "Path to libeay32.dll") +# +# Find DLL to copy/install by iterating DLLS value. +# +# Creates a cache WITH_<NAME> variable with the path to the DLL if found, +# otherwise, set to not found. +# +# If found, WITH_<NAME> is appended to IRCCD_DLLS global variable and set as +# parent scope. +# +# If not found, WITH_<NAME> is appended to IRCCD_DLLS_NOT_FOUND variable. +# - if (EXISTS ${WITH_SSL_EAY_DLL} AND EXISTS ${WITH_SSL_LIB_DLL}) +foreach (name ${DLLS}) + find_program( + WITH_${name} + NAMES ${${name}} + DOC "Path to DLL" + ) + + if (EXISTS ${WITH_${name}}) + file( + COPY ${WITH_${name}} + DESTINATION ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR} + ) install( - PROGRAMS - ${WITH_SSL_EAY_DLL} - ${WITH_SSL_LIB_DLL} + PROGRAMS ${WITH_${name}} COMPONENT libirccd DESTINATION bin ) + list(APPEND IRCCD_DLLS WITH_${name}) + else () + set(IRCCD_PACKAGE Off PARENT_SCOPE) + set(IRCCD_PACKAGE_MSG "No (some .dll were not found)" PARENT_SCOPE) + list(APPEND IRCCD_DLLS_NOT_FOUND WITH_${name}) endif () -endif () +endforeach () + +set(IRCCD_DLLS ${IRCCD_DLLS} PARENT_SCOPE) +set(IRCCD_DLLS_NOT_FOUND ${IRCCD_DLLS_NOT_FOUND} PARENT_SCOPE)