summaryrefslogtreecommitdiff
blob: 2683617871e640abb1eaa5341f72d8bc85ce5dd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
From: Julian Ospald <hasufell@gentoo.org>
Date: Sun Jul 15 10:08:51 UTC 2012
Subject: build system

a. add install rules and make paths modifiable
b. add odamex.wad install destination to wad search path
c. add various cmake options
d. use CMAKE_BINDIR as default bin patch in odalauncher

--- odamex-src-0.6.3/CMakeLists.txt
+++ odamex-src-0.6.3/CMakeLists.txt
@@ -2,6 +2,26 @@
 project(Odamex)
 cmake_minimum_required(VERSION 2.8)
 
+# cmake modules
+include( CMakeDependentOption )
+include( GNUInstallDirs )
+
+# options
+option(BUILD_CLIENT "Build client target" 1)
+option(BUILD_SERVER "Build server target" 1)
+option(BUILD_MASTER "Build master server target" 1)
+cmake_dependent_option( BUILD_ODALAUNCH "Build odalaunch target" 1 BUILD_CLIENT 0 )
+cmake_dependent_option( ENABLE_PORTMIDI "Enable portmidi support" 1 BUILD_CLIENT 0 )
+
+configure_file (
+  "${PROJECT_SOURCE_DIR}/config.h.in"
+  "${PROJECT_BINARY_DIR}/config.h"
+  )
+
+include_directories(
+	${PROJECT_BINARY_DIR}
+)
+
 set(PROJECT_VERSION 0.6.3)
 set(PROJECT_COPYRIGHT "2006-2013")
 
@@ -54,13 +74,30 @@
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
 
 # Subdirectories for individual projects
-add_subdirectory(client)
-add_subdirectory(server)
-add_subdirectory(master)
-add_subdirectory(odalaunch)
+if(BUILD_CLIENT)
+	add_subdirectory(client)
+endif()
+if(BUILD_SERVER)
+	add_subdirectory(server)
+endif()
+if(BUILD_MASTER)
+	add_subdirectory(master)
+endif()
+if(BUILD_ODALAUNCH)
+	add_subdirectory(odalaunch)
+endif()
+
+if(NOT BUILD_CLIENT AND NOT BUILD_SERVER AND NOT BUILD_MASTER)
+	message(FATAL_ERROR "No target chosen, doing nothing.")
+endif()
 
 # Disable the ag-odalaunch target completely: -DNO_AG-ODALAUNCH_TARGET
 # This is only really useful when setting up a universal build.
 if(NOT NO_AG-ODALAUNCH_TARGET)
   add_subdirectory(ag-odalaunch)
 endif()
+
+# global install rules
+if(UNIX)
+	install(FILES odamex.wad DESTINATION ${CMAKE_INSTALL_DATADIR})
+endif()
--- odamex-src-0.6.3/client/CMakeLists.txt
+++ odamex-src-0.6.3/client/CMakeLists.txt
@@ -48,7 +48,7 @@
 
 # PortMidi configuration
 find_package(PortMidi)
-if(PORTMIDI_FOUND)
+if(PORTMIDI_FOUND AND ENABLE_PORTMIDI)
   include_directories(${PORTMIDI_INCLUDE_DIR})
   add_definitions(-DPORTMIDI)
 else()
@@ -95,7 +95,7 @@
   target_link_libraries(odamex ${SDL_LIBRARY})
   target_link_libraries(odamex ${SDLMIXER_LIBRARY})
 
-  if(PORTMIDI_FOUND)
+  if(PORTMIDI_FOUND AND ENABLE_PORTMIDI)
     target_link_libraries(odamex ${PORTMIDI_LIBRARIES})
   endif()
 
@@ -164,5 +164,8 @@
         " )
     endif()
 
+    # UNIX install rules
+    elseif(UNIX)
+	install( TARGETS odamex DESTINATION ${CMAKE_INSTALL_BINDIR} )
   endif()
 endif()
--- odamex-src-0.6.3/master/CMakeLists.txt
+++ odamex-src-0.6.3/master/CMakeLists.txt
@@ -12,3 +12,9 @@
 elseif(SOLARIS)
   target_link_libraries(odamast socket nsl)
 endif()
+
+# install rules
+if(UNIX)
+	install( TARGETS odamast DESTINATION ${CMAKE_INSTALL_BINDIR} )
+endif()
+
--- odamex-src-0.6.3/odalaunch/CMakeLists.txt
+++ odamex-src-0.6.3/odalaunch/CMakeLists.txt
@@ -61,3 +61,9 @@
     )
   endif()
 endif()
+
+# install rules
+if(UNIX)
+	install( TARGETS odalaunch DESTINATION ${CMAKE_INSTALL_BINDIR} )
+endif()
+
--- odamex-src-0.6.3/server/CMakeLists.txt
+++ odamex-src-0.6.3/server/CMakeLists.txt
@@ -56,3 +56,9 @@
 elseif(SOLARIS)
   target_link_libraries(odasrv socket nsl)
 endif()
+
+# install rules
+if(UNIX)
+	install( TARGETS odasrv DESTINATION ${CMAKE_INSTALL_BINDIR} )
+endif()
+
--- /dev/null
+++ odamex-src-0.6.3/config.h.in
@@ -0,0 +1,7 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define CMAKE_WADDIR "@CMAKE_INSTALL_DATADIR@"
+#define CMAKE_BINDIR "@CMAKE_INSTALL_BINDIR@"
+
+#endif
--- odamex-src-0.6.3/common/d_main.cpp
+++ odamex-src-0.6.3/common/d_main.cpp
@@ -23,6 +23,7 @@
 //-----------------------------------------------------------------------------
 
 #include "version.h"
+#include "config.h"
 
 #include <sstream>
 #include <string>
@@ -494,6 +495,7 @@
 	D_AddSearchDir(dirs, getenv("DOOMWADDIR"), separator);
 	D_AddSearchDir(dirs, getenv("DOOMWADPATH"), separator);
 	D_AddSearchDir(dirs, getenv("HOME"), separator);
+	D_AddSearchDir(dirs, CMAKE_WADDIR, separator);
 
 	// [AM] Search additional paths based on platform
 	D_AddPlatformSearchDirs(dirs);
--- odamex-src-0.6.3/odalaunch/src/dlg_main.cpp
+++ odamex-src-0.6.3/odalaunch/src/dlg_main.cpp
@@ -27,6 +27,7 @@
 #include "str_utils.h"
 
 #include "md5.h"
+#include "config.h"
 
 #include <wx/settings.h>
 #include <wx/menu.h>
@@ -42,6 +43,7 @@
 #include <wx/process.h>
 #include <wx/toolbar.h>
 #include <wx/xrc/xmlres.h>
+#include <wx/string.h>
 
 #ifdef __WXMSW__
     #include <windows.h>
@@ -190,10 +192,12 @@
     }
     #endif
 
+    const char *cmake_bindir_str = CMAKE_BINDIR;
+    wxString cmake_bindir = wxString::FromAscii(cmake_bindir_str);
     launchercfg_s.get_list_on_start = 1;
     launchercfg_s.show_blocked_servers = 0;
     launchercfg_s.wad_paths = wxGetCwd();
-    launchercfg_s.odamex_directory = wxGetCwd();
+    launchercfg_s.odamex_directory = cmake_bindir;
 
     m_LstCtrlServers = XRCCTRL(*this, "Id_LstCtrlServers", LstOdaServerList);
     m_LstCtrlPlayers = XRCCTRL(*this, "Id_LstCtrlPlayers", LstOdaPlayerList);