changeset 801:fe27ed0c1eae

windows: cleanup .dll installation
author David Demelier <markand@malikania.fr>
date Mon, 12 Nov 2018 21:47:00 +0100
parents e4662edab00a
children f26bb089232d
files CMakeLists.txt cmake/windows/CMakeLists.txt win32/CMakeLists.txt
diffstat 3 files changed, 93 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Nov 12 21:12:00 2018 +0100
+++ b/CMakeLists.txt	Mon Nov 12 21:47:00 2018 +0100
@@ -47,7 +47,6 @@
 # plugins                   - Official irccd plugins.
 # systemd                   - Unit file for systemd.
 # tests                     - The unit tests.
-# win32                     - Additional files for Windows platform.
 #
 
 cmake_minimum_required(VERSION 3.10)
@@ -105,11 +104,6 @@
 	add_subdirectory(plugins)
 endif ()
 
-# Platform specific.
-if (WIN32)
-	add_subdirectory(win32)
-endif ()
-
 # Tests.
 if (IRCCD_WITH_TESTS)
 	include(CTest)
@@ -118,6 +112,10 @@
 
 add_subdirectory(cmake/export)
 
+if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+	add_subdirectory(cmake/windows)
+endif ()
+
 message("Compiling with the following flags:")
 message("       General flags:  ${CMAKE_CXX_FLAGS}")
 message("       Debug flags:    ${CMAKE_CXX_FLAGS_DEBUG}")
@@ -132,7 +130,6 @@
 message("       User docs:      ${IRCCD_WITH_HTML_MSG}")
 message("       Doxygen:        ${IRCCD_WITH_DOXYGEN_MSG}")
 message("       Package:        ${IRCCD_PACKAGE_MSG}")
-message("       Vera:           ${IRCCD_WITH_VERA_MSG}")
 message("")
 
 message("Installing plugins:")
@@ -142,7 +139,7 @@
 endforeach ()
 message("")
 
-if (WIN32)
+if (CMAKE_SYSTEM_NAME MATCHES "Windows")
 	message("Installing these DLLs:")
 	foreach (name ${IRCCD_DLLS})
 		irccd_indent_message("       ${name}: " "${${name}}" 30)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake/windows/CMakeLists.txt	Mon Nov 12 21:47:00 2018 +0100
@@ -0,0 +1,88 @@
+#
+# CMakeLists.txt -- CMake build system for irccd
+#
+# Copyright (c) 2013-2018 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.
+#
+
+#
+# This file consists of installing required .dll files for Windows.
+#
+# It currently only supports MinGW.
+#
+
+project(windows)
+
+#
+# MinGW libraries.
+# -------------------------------------------------------------------
+#
+
+if (MINGW)
+	if (IRCCD_64BITS)
+		set(LIBGCC_DLL libgcc_s_seh-1.dll)
+	else ()
+		set(LIBGCC_DLL libgcc_s_sjlj-1.dll)
+	endif ()
+
+	set(LIBWINPTHREAD_DLL libwinpthread-1.dll)
+	set(LIBSTDCPP_DLL libstdc++-6.dll)
+	list(APPEND DLLS LIBGCC_DLL LIBWINPTHREAD_DLL LIBSTDCPP_DLL)
+
+	if (IRCCD_HAVE_SSL)
+		set(CRYPTO_DLL libcrypto.dll)
+		set(SSL_DLL libssl.dll)
+		list(APPEND DLLS CRYPTO_DLL SSL_DLL)
+	endif ()
+endif ()
+
+#
+# Find DLL to copy/install by iterating DLLS value.
+#
+# Creates a cache IRCCD_WITH_<NAME> variable with the path to the DLL if found,
+# otherwise, set to not found.
+#
+# If found, IRCCD_WITH_<NAME> is appended to IRCCD_DLLS global variable and set
+# as parent scope.
+#
+# If not found, IRCCD_WITH_<NAME> is appended to IRCCD_DLLS_NOT_FOUND variable.
+#
+
+foreach (name ${DLLS})
+	find_program(
+		IRCCD_WITH_${name}
+		NAMES ${${name}}
+		DOC "Path to ${name} DLL"
+	)
+
+	if (EXISTS ${IRCCD_WITH_${name}})
+		file(
+			COPY ${IRCCD_WITH_${name}}
+			DESTINATION ${CMAKE_BINARY_DIR}/bin
+		)
+		install(
+			PROGRAMS ${IRCCD_WITH_${name}}
+			COMPONENT libirccd
+			DESTINATION bin
+		)
+		list(APPEND FOUND IRCCD_WITH_${name})
+	else ()
+		setg(IRCCD_PACKAGE Off)
+		setg(IRCCD_PACKAGE_MSG "No (some .dll were not found)")
+		list(APPEND NOT_FOUND IRCCD_WITH_${name})
+	endif ()
+endforeach ()
+
+setg(IRCCD_DLLS "${FOUND}")
+setg(IRCCD_DLLS_NOT_FOUND "${NOT_FOUND}")
--- a/win32/CMakeLists.txt	Mon Nov 12 21:12:00 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for irccd
-#
-# Copyright (c) 2013-2018 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.
-#
-
-#
-# This file consists of installing required .dll files for Windows.
-#
-# It currently only supports MinGW.
-#
-
-project(win32)
-
-#
-# MinGW libraries.
-# -------------------------------------------------------------------
-#
-
-if (MINGW)
-	if (IRCCD_64BITS)
-		set(LIBGCC_DLL libgcc_s_seh-1.dll)
-	else ()
-		set(LIBGCC_DLL libgcc_s_sjlj-1.dll)
-	endif ()
-
-	set(LIBWINPTHREAD_DLL libwinpthread-1.dll)
-	set(LIBSTDCPP_DLL libstdc++-6.dll)
-	list(APPEND DLLS LIBGCC_DLL LIBWINPTHREAD_DLL LIBSTDCPP_DLL)
-endif ()
-
-#
-# SSL libraries.
-# -------------------------------------------------------------------
-#
-
-if (IRCCD_HAVE_SSL)
-	set(SSL_EAY_DLL libeay32.dll)
-	set(SSL_LIB_DLL ssleay32.dll)
-	list(APPEND DLLS SSL_EAY_DLL SSL_LIB_DLL)
-endif ()
-
-#
-# Find DLL to copy/install by iterating DLLS value.
-#
-# Creates a cache IRCCD_WITH_<NAME> variable with the path to the DLL if found,
-# otherwise, set to not found.
-#
-# If found, IRCCD_WITH_<NAME> is appended to IRCCD_DLLS global variable and set as
-# parent scope.
-#
-# If not found, IRCCD_WITH_<NAME> is appended to IRCCD_DLLS_NOT_FOUND variable.
-#
-
-foreach (name ${DLLS})
-	find_program(
-		IRCCD_WITH_${name}
-		NAMES ${${name}}
-		DOC "Path to DLL"
-	)
-
-	if (EXISTS ${IRCCD_WITH_${name}})
-		file(
-			COPY ${IRCCD_WITH_${name}}
-			DESTINATION ${IRCCD_FAKEROOTDIR}/${IRCCD_WITH_BINDIR}
-		)
-		install(
-			PROGRAMS ${IRCCD_WITH_${name}}
-			COMPONENT libirccd
-			DESTINATION bin
-		)
-		list(APPEND IRCCD_DLLS IRCCD_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 IRCCD_WITH_${name})
-	endif ()
-endforeach ()
-
-set(IRCCD_DLLS ${IRCCD_DLLS} PARENT_SCOPE)
-set(IRCCD_DLLS_NOT_FOUND ${IRCCD_DLLS_NOT_FOUND} PARENT_SCOPE)