Browse Source

make install should work properly on Mac and Linux

Thomas Buck 9 years ago
parent
commit
012e0fda3a
12 changed files with 117 additions and 22 deletions
  1. 9
    0
      CMakeLists.txt
  2. 6
    0
      ChangeLog.md
  3. 4
    1
      README.md
  4. 4
    1
      cmake/setup.sh
  5. 1
    1
      cmake/setup_mac.sh
  6. 1
    1
      cmake/setup_win.bat
  7. 33
    0
      data/Unix.in
  8. 0
    6
      include/RunTime.h
  9. 9
    3
      include/config.h.in
  10. 30
    5
      src/CMakeLists.txt
  11. 12
    3
      src/config.cpp.in
  12. 8
    1
      src/main.cpp

+ 9
- 0
CMakeLists.txt View File

@@ -82,6 +82,15 @@ add_subdirectory (test)
82 82
 
83 83
 #################################################################
84 84
 
85
+# CPack packaging
86
+include (InstallRequiredSystemLibraries)
87
+set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
88
+set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/COPYING")
89
+set (CPACK_MONOLITHIC_INSTALL YES)
90
+include (CPack)
91
+
92
+#################################################################
93
+
85 94
 if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
86 95
 
87 96
 	# Target for running the setup

+ 6
- 0
ChangeLog.md View File

@@ -2,6 +2,12 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20141010 ]
6
+    * Added CPack packaging to the CMake script
7
+    * Added suitable install target for the Mac App Bundle
8
+    * Now also trying to load config from ${DESTDIR}/etc/OpenRaider.ini if all else fails
9
+    * Added suitable install target for Linux that does not need a setup script
10
+
5 11
     [ 20141008 ]
6 12
     * Added freeGLUT windowing system to use if SDL2 is not available. Not yet working 100%.
7 13
     * Moved unnecessarily duplicated code to Window base class

+ 4
- 1
README.md View File

@@ -69,7 +69,9 @@ Do a standard cmake out-of-source build to get a debug configuration and then ru
69 69
     cmake ..
70 70
     make run
71 71
 
72
-On Mac OS X, running `make install` will produce a (more or less) distributable OpenRaider.app bundle.
72
+On Mac OS X, running `make install` will produce a (more or less) distributable OpenRaider.app bundle, which will be put into /Applications.
73
+
74
+On Linux, running `make install` will install OpenRaider to /usr/local/... (the executable in bin, the config in etc, the data files in share). You can change this path with `make install DESTDIR=”/some/where”`
73 75
 
74 76
 Run `make check` to build and run the unit tests.
75 77
 
@@ -86,6 +88,7 @@ You can also generate working XCode Project files with `cmake -G Xcode ..`.
86 88
 ### Configuration file
87 89
 
88 90
 OpenRaider will try to load `~/.OpenRaider/OpenRaider.ini` or, if it doesn't exist, `OpenRaider.ini` from the current directory.
91
+
89 92
 Running `make setup` will create a minimal configuration in your home directory.
90 93
 
91 94
 The configuration file format is very simple:

+ 4
- 1
cmake/setup.sh View File

@@ -1,13 +1,16 @@
1 1
 #!/bin/sh
2 2
 
3 3
 echo "Setting up OpenRaider for user $USER..."
4
+
4 5
 mkdir -p ~/.OpenRaider
5
-cp data/OpenRaider.ini ~/.OpenRaider/
6 6
 mkdir -p ~/.OpenRaider/paks
7 7
 mkdir -p ~/.OpenRaider/music
8 8
 mkdir -p ~/.OpenRaider/data
9 9
 mkdir -p ~/.OpenRaider/sshots
10
+
11
+cp data/OpenRaider.ini ~/.OpenRaider/
10 12
 cp data/*.tga ~/.OpenRaider/data
11 13
 cp data/*.ttf ~/.OpenRaider/data
12 14
 cp data/*.pc ~/.OpenRaider/data
15
+
13 16
 echo "DONE"

+ 1
- 1
cmake/setup_mac.sh View File

@@ -3,11 +3,11 @@ cd `dirname $0`
3 3
 if [ ! -d "${HOME}/.OpenRaider" ]; then
4 4
     echo "Setting up OpenRaider for user $USER..."
5 5
     mkdir -p ~/.OpenRaider
6
-    cp ../Resources/defaults/OpenRaider.ini ~/.OpenRaider/
7 6
     mkdir -p ~/.OpenRaider/paks
8 7
     mkdir -p ~/.OpenRaider/music
9 8
     mkdir -p ~/.OpenRaider/data
10 9
     mkdir -p ~/.OpenRaider/sshots
10
+    cp ../Resources/defaults/OpenRaider.ini ~/.OpenRaider/
11 11
     cp ../Resources/defaults/*.tga ~/.OpenRaider/data
12 12
     cp ../Resources/defaults/*.ttf ~/.OpenRaider/data
13 13
     cp ../Resources/defaults/*.pc ~/.OpenRaider/data

+ 1
- 1
cmake/setup_win.bat View File

@@ -3,11 +3,11 @@
3 3
 if not exist "%UserProfile%\.OpenRaider" (
4 4
 	echo Setting up for %UserName%...
5 5
 	mkdir "%UserProfile%\.OpenRaider"
6
-	copy data\OpenRaider.ini %UserProfile%\.OpenRaider
7 6
 	mkdir %UserProfile%\.OpenRaider\paks
8 7
 	mkdir %UserProfile%\.OpenRaider\music
9 8
 	mkdir %UserProfile%\.OpenRaider\data
10 9
 	mkdir %UserProfile%\.OpenRaider\sshots
10
+	copy data\OpenRaider.ini %UserProfile%\.OpenRaider
11 11
 	copy data\*.tga %UserProfile%\.OpenRaider\data
12 12
 	copy data\*.ttf %UserProfile%\.OpenRaider\data
13 13
 	copy data\*.pc %UserProfile%\.OpenRaider\data

+ 33
- 0
data/Unix.in View File

@@ -0,0 +1,33 @@
1
+# OpenRaider configuration file
2
+
3
+# File locations
4
+set basedir    "@CMAKE_INSTALL_PREFIX@"
5
+set datadir    "$(basedir)/share/OpenRaider"
6
+set pakdir     "$(datadir)"
7
+set audiodir   "$(datadir)"
8
+set font       "$(datadir)/test.ttf"
9
+# set font       "$(datadir)/font.pc"
10
+
11
+# Windowing
12
+set size       1280 720
13
+set fullscreen false
14
+
15
+# Audio
16
+set audio      true # Enable Audio Output
17
+set volume     0.5
18
+
19
+# Input
20
+set mouse_x    0.75
21
+set mouse_y    0.75
22
+
23
+bind menu     "escape"
24
+bind debug    'q'
25
+bind forward  'w'
26
+bind backward 's'
27
+bind left     'a'
28
+bind right    'd'
29
+bind jump     "space"
30
+bind crouch   "leftctrl"
31
+bind use      "leftmouse"
32
+bind holster  "rightmouse"
33
+bind walk     "leftshift"

+ 0
- 6
include/RunTime.h View File

@@ -10,12 +10,6 @@
10 10
 
11 11
 #include <string>
12 12
 
13
-// Defaults
14
-#define DEFAULT_CONFIG_PATH "~/.OpenRaider"
15
-#define DEFAULT_CONFIG_FILE "OpenRaider.ini"
16
-#define DEFAULT_WIDTH 1280
17
-#define DEFAULT_HEIGHT 720
18
-
19 13
 /*!
20 14
  * \brief Main Game Singleton
21 15
  */

+ 9
- 3
include/config.h.in View File

@@ -8,9 +8,15 @@
8 8
 #ifndef _CONFIG_H_
9 9
 #define _CONFIG_H_
10 10
 
11
-extern const char *VERSION;
12
-extern const char *VERSION_SHORT;
13
-extern const char *BUILD_HOST;
11
+extern const unsigned int DEFAULT_WIDTH;
12
+extern const unsigned int DEFAULT_HEIGHT;
13
+
14
+extern const char* VERSION;
15
+extern const char* VERSION_SHORT;
16
+extern const char* BUILD_HOST;
17
+extern const char* DEFAULT_CONFIG_PATH;
18
+extern const char* DEFAULT_CONFIG_FILE;
19
+extern const char* INSTALL_PREFIX;
14 20
 
15 21
 #cmakedefine USING_AL
16 22
 #cmakedefine USING_PNG

+ 30
- 5
src/CMakeLists.txt View File

@@ -272,12 +272,37 @@ endif (APPLE)
272 272
 
273 273
 #################################################################
274 274
 
275
-if (NOT APPLE)
276
-    # Install binary
277
-    install (TARGETS OpenRaider
278
-        RUNTIME DESTINATION bin
275
+# Install rules
276
+if (APPLE)
277
+    # We want to install to /Applications by default, not /usr
278
+    set (OR_INSTALL_PREFIX "/" CACHE PATH "Prefix prepended to
279
+install directories")
280
+    set (CMAKE_INSTALL_PREFIX "${OR_INSTALL_PREFIX}" CACHE INTERNAL "Prefix
281
+prepended to install directories" FORCE)
282
+
283
+    # Only the App Bundle is required on OS X
284
+    install (TARGETS OpenRaider BUNDLE DESTINATION Applications)
285
+elseif (NOT WIN32)
286
+    # We need a special config file for this install method
287
+    configure_file (
288
+        "${PROJECT_SOURCE_DIR}/data/Unix.in"   
289
+        "${PROJECT_BINARY_DIR}/Unix.ini"
279 290
     )
280
-endif (NOT APPLE)
291
+
292
+    # Executable
293
+    install (TARGETS OpenRaider RUNTIME DESTINATION bin)
294
+
295
+    # Config file
296
+    install (FILES "${PROJECT_BINARY_DIR}/Unix.ini"
297
+        DESTINATION etc
298
+        RENAME "OpenRaider.ini")
299
+
300
+    # Data files
301
+    install (FILES "${PROJECT_SOURCE_DIR}/data/font.pc"
302
+                    "${PROJECT_SOURCE_DIR}/data/splash.tga"
303
+                    "${PROJECT_SOURCE_DIR}/data/test.ttf"
304
+        DESTINATION "share/OpenRaider")
305
+endif (APPLE)
281 306
 
282 307
 #################################################################
283 308
 

+ 12
- 3
src/config.cpp.in View File

@@ -7,9 +7,18 @@
7 7
 
8 8
 #include "global.h"
9 9
 
10
-const char *VERSION = "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)";
10
+const unsigned int DEFAULT_WIDTH = 1280;
11
+const unsigned int DEFAULT_HEIGHT = 720;
11 12
 
12
-const char *VERSION_SHORT = "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@";
13
+const char* VERSION = "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)";
13 14
 
14
-const char *BUILD_HOST = "@OpenRaider_BUILD_HOST@ @OpenRaider_HOSTNAME@";
15
+const char* VERSION_SHORT = "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@";
16
+
17
+const char* BUILD_HOST = "@OpenRaider_BUILD_HOST@ @OpenRaider_HOSTNAME@";
18
+
19
+const char* DEFAULT_CONFIG_PATH = "~/.OpenRaider";
20
+
21
+const char* DEFAULT_CONFIG_FILE = "OpenRaider.ini";
22
+
23
+const char* INSTALL_PREFIX = "@CMAKE_INSTALL_PREFIX@";
15 24
 

+ 8
- 1
src/main.cpp View File

@@ -151,7 +151,14 @@ int main(int argc, char* argv[]) {
151 151
     // So we need to initialize some things before executing the config
152 152
     if (configFileToUse == "") {
153 153
         if (Command::executeFile(DEFAULT_CONFIG_FILE) != 0) {
154
-            Command::executeFile(DEFAULT_CONFIG_PATH "/" DEFAULT_CONFIG_FILE);
154
+            if (Command::executeFile(std::string(DEFAULT_CONFIG_PATH) + "/" + DEFAULT_CONFIG_FILE) != 0) {
155
+                std::string p = INSTALL_PREFIX;
156
+                if (p == "/")
157
+                    p += "etc/";
158
+                else
159
+                    p += "/etc/";
160
+                Command::executeFile(p + DEFAULT_CONFIG_FILE);
161
+            }
155 162
         }
156 163
     } else {
157 164
         Command::executeFile(configFileToUse);

Loading…
Cancel
Save