From c7feefbfcab5a4de39c73d9860bddfae6092f7cd Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Fri, 9 Jan 2015 08:31:40 +0100
Subject: [PATCH] Reorganized packaging CMake code.

---
 CMakeLists.txt                               |  2 +-
 scripts/cmake/packaging/Pack.cmake           | 72 ++++++--------------
 scripts/cmake/packaging/PackagingLinux.cmake |  1 +
 scripts/cmake/packaging/PackagingMac.cmake   | 11 +++
 scripts/cmake/packaging/PackagingWin.cmake   | 19 ++++++
 5 files changed, 54 insertions(+), 51 deletions(-)
 create mode 100644 scripts/cmake/packaging/PackagingLinux.cmake
 create mode 100644 scripts/cmake/packaging/PackagingMac.cmake
 create mode 100644 scripts/cmake/packaging/PackagingWin.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7de12a86fa..4689c355f8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,7 +94,7 @@ OPTION(OGS_COVERAGE "Enables code coverage measurements with gcov/lcov." OFF)
 IF(WIN32)
 	OPTION(OGS_PACKAGING_NSIS "Do you want to package with NSIS?")
 ENDIF()
-INCLUDE(scripts/cmake/Pack.cmake)
+INCLUDE(scripts/cmake/packaging/Pack.cmake)
 
 ######################
 ### Subdirectories ###
diff --git a/scripts/cmake/packaging/Pack.cmake b/scripts/cmake/packaging/Pack.cmake
index d668b635167..f081f336859 100644
--- a/scripts/cmake/packaging/Pack.cmake
+++ b/scripts/cmake/packaging/Pack.cmake
@@ -9,60 +9,32 @@ SET(CPACK_PACKAGE_VERSION_MINOR "${OGS_VERSION_MINOR}")
 SET(CPACK_PACKAGE_VERSION_PATCH "${OGS_VERSION_PATCH}")
 SET(CPACK_PACKAGE_FILE_NAME "ogs-${OGS_VERSION}-${CMAKE_SYSTEM}-x${BITS}")
 
+IF (WIN32)
+	INCLUDE (packaging/PackagingWin)
+ENDIF()
+IF(UNIX)
+	INCLUDE (packaging/PackagingLinux)
+ENDIF()
 IF(APPLE)
-	IF(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
-		SET(CMAKE_INSTALL_PREFIX "/Applications")
-	ENDIF()
-	SET(CMAKE_OSX_ARCHITECTURES "x86_64")
-	SET(CPACK_GENERATOR "DragNDrop")
-	SET(CPACK_DMG_FORMAT "UDBZ")
-	SET(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
-	# See http://stackoverflow.com/a/16662169/80480 how to create the DS_Store file.
-	SET(CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_SOURCE_DIR}/Documentation/OpenGeoSys-Logo.png)
-	SET(CPACK_DMG_DS_STORE ${CMAKE_SOURCE_DIR}/scripts/packaging/.DS_Store)
-	SET(CPACK_SYSTEM_NAME "OSX")
-ELSE() # APPLE
-	IF (WIN32)
-		IF(OGS_PACKAGING_NSIS)
-			SET(CPACK_GENERATOR NSIS)
-			# There is a bug in NSI that does not handle full unix paths properly. Make
-			# sure there is at least one set of four (4) backlasshes.
-			#SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/CMakeConfiguration\\\\OGS_Logo_Installer.bmp")
-			#SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
-			SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
-			SET(CPACK_NSIS_HELP_LINK "https:\\\\\\\\www.opengeosys.org")
-			SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.opengeosys.org")
-			SET(CPACK_NSIS_CONTACT "info@opengeosys.org")
-			SET(CPACK_NSIS_MODIFY_PATH ON)
-			# SET(CPACK_NSIS_MENU_LINKS "http://www.opengeosys.org" "OGS Project Page")
-			# SET(CPACK_NSIS_MENU_LINKS "http://www.opengeosys.org/forum/" "OGS forum")
-			# SET(CPACK_NSIS_MENU_LINKS "https://github.com/ufz/ogs" "OGS source code")
-			# SET(CPACK_NSIS_MENU_LINKS "http://devguide.opengeosys.org" "OGS developer guide")
-		ELSE()
-			SET(CPACK_GENERATOR ZIP)
-			SET(CPACK_PACKAGE_FILE_NAME "ogs-6")
-		ENDIF()
-	ENDIF() # WIN32
+	INCLUDE (packaging/PackagingMac)
+ENDIF()
+
 
-	IF(UNIX)
-		SET(CPACK_GENERATOR TGZ)
-	ENDIF()
+SET(CPACK_COMPONENT_OGS_DISPLAY_NAME "Executable")
+SET(CPACK_COMPONENT_OGS_DESCRIPTION "The command line executable")
 
-	SET(CPACK_COMPONENT_OGS_DISPLAY_NAME "Executable")
-	SET(CPACK_COMPONENT_OGS_DESCRIPTION "The command line executable")
+SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
+IF(OGS_BUILD_GUI)
+	SET(CPACK_PACKAGE_EXECUTABLES "DataExplorer" "OGS User Interface")
+	SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ogs_gui Unspecified)
+	SET(CPACK_COMPONENT_OGS_GUI_DISPLAY_NAME "Data Explorer")
+	SET(CPACK_COMPONENT_OGS_GUI_DESCRIPTION "The graphical user interface for OpenGeoSys")
+	#SET(CPACK_COMPONENT_OGS_GUI_DEPENDS ogs)
+ELSE()
+	# SET(CPACK_PACKAGE_EXECUTABLES "ogs" "OGS Command Line")
+	# SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ogs Unspecified)
+ENDIF()
 
-	SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
-	IF(OGS_BUILD_GUI)
-		SET(CPACK_PACKAGE_EXECUTABLES "DataExplorer" "OGS User Interface")
-		SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ogs_gui Unspecified)
-		SET(CPACK_COMPONENT_OGS_GUI_DISPLAY_NAME "Data Explorer")
-		SET(CPACK_COMPONENT_OGS_GUI_DESCRIPTION "The graphical user interface for OpenGeoSys")
-		#SET(CPACK_COMPONENT_OGS_GUI_DEPENDS ogs)
-	ELSE()
-		# SET(CPACK_PACKAGE_EXECUTABLES "ogs" "OGS Command Line")
-		# SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ogs Unspecified)
-	ENDIF()
-ENDIF() # APPLE
 
 # Additional binaries, i.e. OGS-5 file converter
 # Can be given as a list, paths must be relative to CMAKE_BINARY_DIR!
diff --git a/scripts/cmake/packaging/PackagingLinux.cmake b/scripts/cmake/packaging/PackagingLinux.cmake
new file mode 100644
index 00000000000..e9be72d60b7
--- /dev/null
+++ b/scripts/cmake/packaging/PackagingLinux.cmake
@@ -0,0 +1 @@
+SET(CPACK_GENERATOR TGZ)
diff --git a/scripts/cmake/packaging/PackagingMac.cmake b/scripts/cmake/packaging/PackagingMac.cmake
new file mode 100644
index 00000000000..6928c27ab43
--- /dev/null
+++ b/scripts/cmake/packaging/PackagingMac.cmake
@@ -0,0 +1,11 @@
+IF(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
+	SET(CMAKE_INSTALL_PREFIX "/Applications")
+ENDIF()
+SET(CMAKE_OSX_ARCHITECTURES "x86_64")
+SET(CPACK_GENERATOR "DragNDrop")
+SET(CPACK_DMG_FORMAT "UDBZ")
+SET(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
+# See http://stackoverflow.com/a/16662169/80480 how to create the DS_Store file.
+SET(CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_SOURCE_DIR}/Documentation/OpenGeoSys-Logo.png)
+SET(CPACK_DMG_DS_STORE ${CMAKE_SOURCE_DIR}/scripts/packaging/.DS_Store)
+SET(CPACK_SYSTEM_NAME "OSX")
diff --git a/scripts/cmake/packaging/PackagingWin.cmake b/scripts/cmake/packaging/PackagingWin.cmake
new file mode 100644
index 00000000000..0b54136ba5b
--- /dev/null
+++ b/scripts/cmake/packaging/PackagingWin.cmake
@@ -0,0 +1,19 @@
+IF(OGS_PACKAGING_NSIS)
+	SET(CPACK_GENERATOR NSIS)
+	# There is a bug in NSI that does not handle full unix paths properly. Make
+	# sure there is at least one set of four (4) backlasshes.
+	#SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/CMakeConfiguration\\\\OGS_Logo_Installer.bmp")
+	#SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
+	SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
+	SET(CPACK_NSIS_HELP_LINK "https:\\\\\\\\www.opengeosys.org")
+	SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.opengeosys.org")
+	SET(CPACK_NSIS_CONTACT "info@opengeosys.org")
+	SET(CPACK_NSIS_MODIFY_PATH ON)
+	# SET(CPACK_NSIS_MENU_LINKS "http://www.opengeosys.org" "OGS Project Page")
+	# SET(CPACK_NSIS_MENU_LINKS "http://www.opengeosys.org/forum/" "OGS forum")
+	# SET(CPACK_NSIS_MENU_LINKS "https://github.com/ufz/ogs" "OGS source code")
+	# SET(CPACK_NSIS_MENU_LINKS "http://devguide.opengeosys.org" "OGS developer guide")
+ELSE()
+	SET(CPACK_GENERATOR ZIP)
+	SET(CPACK_PACKAGE_FILE_NAME "ogs-6")
+ENDIF()
-- 
GitLab