Browse Source

cmake changes to make SDL optional in the future

Thomas Buck 10 years ago
parent
commit
df70e557c7
4 changed files with 54 additions and 37 deletions
  1. 0
    6
      CMakeLists.txt
  2. 1
    0
      cmake/Config.h.in
  3. 5
    0
      include/WindowSDL.h
  4. 48
    31
      src/CMakeLists.txt

+ 0
- 6
CMakeLists.txt View File

@@ -20,12 +20,6 @@ endif()
20 20
 
21 21
 #################################################################
22 22
 
23
-# Configuration Header file
24
-configure_file (
25
-    "${PROJECT_SOURCE_DIR}/cmake/Config.h.in"
26
-    "${PROJECT_BINARY_DIR}/Config.h"
27
-)
28
-
29 23
 # Include directories
30 24
 include_directories ("${PROJECT_SOURCE_DIR}/include")
31 25
 include_directories ("${PROJECT_BINARY_DIR}")

+ 1
- 0
cmake/Config.h.in View File

@@ -1,2 +1,3 @@
1 1
 #define VERSION "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)"
2 2
 #define BUILD_HOST "@OpenRaider_BUILD_HOST@"
3
+

+ 5
- 0
include/WindowSDL.h View File

@@ -8,6 +8,8 @@
8 8
 #ifndef _WINDOW_SDL_H_
9 9
 #define _WINDOW_SDL_H_
10 10
 
11
+#include "SDL.h"
12
+
11 13
 #include "Window.h"
12 14
 
13 15
 /*!
@@ -39,6 +41,9 @@ private:
39 41
     unsigned int mHeight;
40 42
     bool mFullscreen;
41 43
     bool mMousegrab;
44
+
45
+    SDL_Window *mWindow;      //!< This is the pointer to the SDL surface
46
+    SDL_GLContext mGLContext; //!< The OpenGL Context
42 47
 };
43 48
 
44 49
 #endif

+ 48
- 31
src/CMakeLists.txt View File

@@ -1,8 +1,55 @@
1
+# Add SDL2 Library
2
+find_package (SDL2)
3
+include_directories (SYSTEM ${SDL2_INCLUDE_DIR})
4
+set (LIBS ${LIBS} ${SDL2_LIBRARY})
5
+
6
+# Add SDL2_ttf Library
7
+find_package (SDL2TTF)
8
+include_directories (SYSTEM ${SDL2TTF_INCLUDE_DIR})
9
+set (LIBS ${LIBS} ${SDL2TTF_LIBRARY})
10
+
11
+# Add OpenGL Library
12
+find_package (OpenGL REQUIRED)
13
+include_directories (SYSTEM ${OPENGL_INCLUDE_DIRS})
14
+set (LIBS ${LIBS} ${OPENGL_LIBRARIES})
15
+
16
+# Add OpenAL Library
17
+find_package (OpenAL REQUIRED)
18
+include_directories (SYSTEM ${OPENAL_INCLUDE_DIRS})
19
+set (LIBS ${LIBS} ${OPENAL_LIBRARIES})
20
+
21
+# Add ALUT Library
22
+find_package (ALUT REQUIRED)
23
+include_directories (SYSTEM ${ALUT_INCLUDE_DIRS})
24
+set (LIBS ${LIBS} ${ALUT_LIBRARIES})
25
+
26
+# Add Z Library
27
+find_package (ZLIB REQUIRED)
28
+include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS})
29
+set (LIBS ${LIBS} ${ZLIB_LIBRARIES})
30
+
31
+#################################################################
32
+
1 33
 # Set Source files
2 34
 set (SRCS ${SRCS} "main.cpp")
3 35
 set (SRCS ${SRCS} "OpenRaider.cpp")
4 36
 set (SRCS ${SRCS} "Sound.cpp")
5
-set (SRCS ${SRCS} "WindowSDL.cpp")
37
+
38
+# Select available Windowing library
39
+if (SDL2_FOUND AND SDL2TTF_FOUND)
40
+    set (SRCS ${SRCS} "WindowSDL.cpp")
41
+else (SDL2_FOUND AND SDL2TTF_FOUND)
42
+    # Currently only SDL2 support
43
+    message (FATAL_ERROR "SDL2 and SDL2-TTF are required!")
44
+endif (SDL2_FOUND AND SDL2TTF_FOUND)
45
+
46
+#################################################################
47
+
48
+# Configuration Header file
49
+configure_file (
50
+    "${PROJECT_SOURCE_DIR}/cmake/Config.h.in"
51
+    "${PROJECT_BINARY_DIR}/Config.h"
52
+)
6 53
 
7 54
 #################################################################
8 55
 
@@ -120,36 +167,6 @@ endif (NOT APPLE)
120 167
 # Add Math Library
121 168
 set (LIBS ${LIBS} m)
122 169
 
123
-# Add SDL2 Library
124
-find_package (SDL2 REQUIRED)
125
-include_directories (SYSTEM ${SDL2_INCLUDE_DIR})
126
-set (LIBS ${LIBS} ${SDL2_LIBRARY})
127
-
128
-# Add SDL2_ttf Library
129
-find_package (SDL2TTF REQUIRED)
130
-include_directories (SYSTEM ${SDL2TTF_INCLUDE_DIR})
131
-set (LIBS ${LIBS} ${SDL2TTF_LIBRARY})
132
-
133
-# Add OpenGL Library
134
-find_package (OpenGL REQUIRED)
135
-include_directories (SYSTEM ${OPENGL_INCLUDE_DIRS})
136
-set (LIBS ${LIBS} ${OPENGL_LIBRARIES})
137
-
138
-# Add OpenAL Library
139
-find_package (OpenAL REQUIRED)
140
-include_directories (SYSTEM ${OPENAL_INCLUDE_DIRS})
141
-set (LIBS ${LIBS} ${OPENAL_LIBRARIES})
142
-
143
-# Add ALUT Library
144
-find_package (ALUT REQUIRED)
145
-include_directories (SYSTEM ${ALUT_INCLUDE_DIRS})
146
-set (LIBS ${LIBS} ${ALUT_LIBRARIES})
147
-
148
-# Add Z Library
149
-find_package (ZLIB REQUIRED)
150
-include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS})
151
-set (LIBS ${LIBS} ${ZLIB_LIBRARIES})
152
-
153 170
 # Add utils Library
154 171
 set (LIBS ${LIBS} OpenRaider_math)
155 172
 set (LIBS ${LIBS} OpenRaider_utils)

Loading…
Cancel
Save