Преглед изворни кода

Added SLOP_OPENGL flag that makes OpenGL optional. (You shouldn't want this.)

naelstrof пре 6 година
родитељ
комит
e9bc4a7e22
2 измењених фајлова са 77 додато и 34 уклоњено
  1. 64
    34
      CMakeLists.txt
  2. 13
    0
      src/slop.cpp

+ 64
- 34
CMakeLists.txt Прегледај датотеку

1
 cmake_minimum_required(VERSION 3.1.3)
1
 cmake_minimum_required(VERSION 3.1.3)
2
 
2
 
3
 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)")
3
 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)")
4
+
4
 if ( NOT CMAKE_INSTALL_PREFIX )
5
 if ( NOT CMAKE_INSTALL_PREFIX )
5
     set(CMAKE_INSTALL_PREFIX "/usr")
6
     set(CMAKE_INSTALL_PREFIX "/usr")
6
 endif()
7
 endif()
7
 
8
 
9
+# This should really never be disabled. The pure-X mode of slop is very expensive and buggy.
10
+# It also doesn't work on Wayland. Though if a system is never running a compositor, or
11
+# doesn't have OpenGL, this could remove some linking dependencies I suppose.
12
+set( SLOP_OPENGL TRUE CACHE BOOL "To enable or disable OpenGL support." )
13
+if ( SLOP_OPENGL )
14
+  add_definitions(-DSLOP_OPENGL="True")
15
+endif()
16
+
8
 project(slop)
17
 project(slop)
9
 
18
 
10
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
19
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
21
 
30
 
22
 include_directories("${PROJECT_BINARY_DIR}")
31
 include_directories("${PROJECT_BINARY_DIR}")
23
 
32
 
24
-add_definitions(-DSLOP_VERSION="v7.3.48")
33
+add_definitions(-DSLOP_VERSION="v7.3.49")
25
 
34
 
26
 # The names have to be unique unfortunately.
35
 # The names have to be unique unfortunately.
27
 set(EXECUTABLE_NAME "slop")
36
 set(EXECUTABLE_NAME "slop")
28
 set(LIBRARY_NAME "slopy")
37
 set(LIBRARY_NAME "slopy")
29
 
38
 
30
-add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
31
-                                    src/keyboard.cpp
32
-                                    src/x.cpp
33
-                                    src/slopstates.cpp
34
-                                    src/framebuffer.cpp
35
-                                    src/resource.cpp
36
-                                    src/shader.cpp
37
-                                    src/window.cpp
38
-                                    src/slop.cpp
39
-                                    src/rectangle.cpp
40
-                                    src/xshaperectangle.cpp
41
-                                    src/glrectangle.cpp)
39
+
40
+if ( SLOP_OPENGL )
41
+  add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
42
+                                      src/keyboard.cpp
43
+                                      src/x.cpp
44
+                                      src/slopstates.cpp
45
+                                      src/resource.cpp
46
+                                      src/slop.cpp
47
+                                      src/rectangle.cpp
48
+                                      src/xshaperectangle.cpp
49
+                                      src/shader.cpp
50
+                                      src/window.cpp
51
+                                      src/framebuffer.cpp
52
+                                      src/glrectangle.cpp)
53
+else()
54
+  add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
55
+                                      src/keyboard.cpp
56
+                                      src/x.cpp
57
+                                      src/slopstates.cpp
58
+                                      src/resource.cpp
59
+                                      src/slop.cpp
60
+                                      src/rectangle.cpp
61
+                                      src/xshaperectangle.cpp)
62
+endif()
42
 
63
 
43
 set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
64
 set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
44
 set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD 11)
65
 set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD 11)
50
 
71
 
51
 set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
72
 set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
52
 
73
 
53
-find_package(GLEW REQUIRED)
54
 find_package(GLM REQUIRED)
74
 find_package(GLM REQUIRED)
55
 find_package(X11 REQUIRED)
75
 find_package(X11 REQUIRED)
56
 find_package(XExt REQUIRED)
76
 find_package(XExt REQUIRED)
57
-find_package(GLX REQUIRED)
58
-find_package(OpenGL REQUIRED)
59
-find_package(XRender REQUIRED)
60
-# Ahhhh, finally this eliminates the segfault on preload.
61
-find_package(Threads REQUIRED)
77
+
78
+if ( SLOP_OPENGL )
79
+  find_package(GLEW REQUIRED)
80
+  find_package(OpenGL REQUIRED)
81
+  find_package(GLX REQUIRED)
82
+  find_package(XRender REQUIRED)
83
+  # Ahhhh, finally this eliminates the segfault on preload.
84
+  find_package(Threads REQUIRED)
85
+endif()
62
 
86
 
63
 include_directories(${X11_INCLUDE_DIR}
87
 include_directories(${X11_INCLUDE_DIR}
64
-                    ${GLEW_INCLUDE_DIR}
65
                     ${GLM_INCLUDE_DIR}
88
                     ${GLM_INCLUDE_DIR}
66
-                    ${XEXT_INCLUDE_DIR}
67
-                    ${GLX_INCLUDE_DIR}
68
-                    ${XRENDER_INCLUDE_DIR}
69
-                    ${OPENGL_INCLUDE_DIR})
89
+                    ${GLX_INCLUDE_DIR})
70
 
90
 
71
 target_link_libraries(${LIBRARY_NAME} ${X11_LIBRARIES}
91
 target_link_libraries(${LIBRARY_NAME} ${X11_LIBRARIES}
72
-                                      ${CMAKE_THREAD_LIBS_INIT} 
73
                                       ${GLM_LIBRARIES}
92
                                       ${GLM_LIBRARIES}
74
-                                      ${OPENGL_LIBRARIES}
75
-                                      ${GLX_LIBRARY}
76
-                                      ${XRENDER_LIBRARY}
77
-                                      ${XEXT_LIBRARIES}
78
-                                      ${GLEW_LIBRARIES})
93
+                                      ${XEXT_LIBRARIES})
94
+
95
+if ( SLOP_OPENGL )
96
+  include_directories( ${XEXT_INCLUDE_DIR}
97
+                       ${GLEW_INCLUDE_DIR}
98
+                       ${XRENDER_INCLUDE_DIR}
99
+                       ${OPENGL_INCLUDE_DIR} )
100
+  target_link_libraries(${LIBRARY_NAME} ${OPENGL_LIBRARIES}
101
+                                        ${XRENDER_LIBRARY}
102
+                                        ${CMAKE_THREAD_LIBS_INIT} 
103
+                                        ${GLX_LIBRARY}
104
+                                        ${GLEW_LIBRARIES})
105
+endif()
79
 
106
 
80
 target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} )
107
 target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} )
81
 
108
 
82
-find_package(ICU COMPONENTS uc)
83
-set( SLOP_UNICODE TRUE CACHE BOOL "To enable or disable unicode support." )
84
-if ( SLOP_UNICODE AND ICU_FOUND )
85
-    # ICU is required for old nvidia drivers to work for whatever reason.
109
+if( CMAKE<3.7 )
110
+  message( WARNING "CMake version is below 3.7, CMake version >= 3.7 is required for unicode support." )
111
+else()
112
+  find_package(ICU COMPONENTS uc)
113
+  set( SLOP_UNICODE TRUE CACHE BOOL "To enable or disable unicode support." )
114
+  if ( SLOP_UNICODE AND ICU_FOUND )
86
     add_definitions(-DCXXOPTS_USE_UNICODE)
115
     add_definitions(-DCXXOPTS_USE_UNICODE)
87
     include_directories( ${ICU_INCLUDE_DIR} )
116
     include_directories( ${ICU_INCLUDE_DIR} )
88
     target_link_libraries(${EXECUTABLE_NAME} ${ICU_UC_LIBRARIES} )
117
     target_link_libraries(${EXECUTABLE_NAME} ${ICU_UC_LIBRARIES} )
118
+  endif()
89
 endif()
119
 endif()
90
 
120
 
91
 install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
121
 install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )

+ 13
- 0
src/slop.cpp Прегледај датотеку

1
+#ifdef SLOP_OPENGL
1
 #include <GL/glew.h>
2
 #include <GL/glew.h>
2
 #include <GL/gl.h>
3
 #include <GL/gl.h>
4
+#endif
3
 
5
 
4
 #include <chrono>
6
 #include <chrono>
5
 #include <thread>
7
 #include <thread>
13
 #include "resource.hpp"
15
 #include "resource.hpp"
14
 #include "keyboard.hpp"
16
 #include "keyboard.hpp"
15
 
17
 
18
+#ifdef SLOP_OPENGL
16
 #include "window.hpp"
19
 #include "window.hpp"
17
 #include "shader.hpp"
20
 #include "shader.hpp"
18
 #include "framebuffer.hpp"
21
 #include "framebuffer.hpp"
19
 #include "glrectangle.hpp"
22
 #include "glrectangle.hpp"
23
+#endif
24
+
20
 #include "xshaperectangle.hpp"
25
 #include "xshaperectangle.hpp"
21
 #include "slop.hpp"
26
 #include "slop.hpp"
22
 
27
 
27
 Keyboard* keyboard;
32
 Keyboard* keyboard;
28
 Resource* resource;
33
 Resource* resource;
29
 
34
 
35
+#ifdef SLOP_OPENGL
30
 SlopSelection GLSlopSelect( slop::SlopOptions* options, slop::SlopWindow* window );
36
 SlopSelection GLSlopSelect( slop::SlopOptions* options, slop::SlopWindow* window );
37
+#endif
31
 SlopSelection XShapeSlopSelect( slop::SlopOptions* options );
38
 SlopSelection XShapeSlopSelect( slop::SlopOptions* options );
32
 
39
 
33
 static int TmpXError(Display * d, XErrorEvent * ev) {
40
 static int TmpXError(Display * d, XErrorEvent * ev) {
106
         keyboard = new Keyboard( x11 );
113
         keyboard = new Keyboard( x11 );
107
         XSetErrorHandler(ph);
114
         XSetErrorHandler(ph);
108
     }
115
     }
116
+#ifdef SLOP_OPENGL
109
     bool success = false;
117
     bool success = false;
110
     std::string errorstring = "";
118
     std::string errorstring = "";
111
     SlopWindow* window;
119
     SlopWindow* window;
138
                 std::cerr << errorstring;
146
                 std::cerr << errorstring;
139
             }
147
             }
140
         }
148
         }
149
+#endif // SLOP_OPENGL
141
         returnval = slop::XShapeSlopSelect( options );
150
         returnval = slop::XShapeSlopSelect( options );
151
+#ifdef SLOP_OPENGL
142
     } else {
152
     } else {
143
         returnval = slop::GLSlopSelect( options, window );
153
         returnval = slop::GLSlopSelect( options, window );
144
     }
154
     }
155
+#endif
145
     delete x11;
156
     delete x11;
146
     delete slop::resource;
157
     delete slop::resource;
147
     if ( deleteOptions ) {
158
     if ( deleteOptions ) {
209
     return slop::SlopSelection( output.x, output.y, output.z, output.w, selectedWindow, cancelled );
220
     return slop::SlopSelection( output.x, output.y, output.z, output.w, selectedWindow, cancelled );
210
 }
221
 }
211
 
222
 
223
+#ifdef SLOP_OPENGL
212
 slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, SlopWindow* window ) {
224
 slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, SlopWindow* window ) {
213
     bool cancelled = false;
225
     bool cancelled = false;
214
     slop::mouse = new slop::Mouse( x11, options->nodecorations, window->window );
226
     slop::mouse = new slop::Mouse( x11, options->nodecorations, window->window );
342
     // Finally return the data.
354
     // Finally return the data.
343
     return slop::SlopSelection( output.x, output.y, output.z, output.w, selectedWindow, cancelled );
355
     return slop::SlopSelection( output.x, output.y, output.z, output.w, selectedWindow, cancelled );
344
 }
356
 }
357
+#endif
345
 
358
 
346
 extern "C" struct slop_options slop_options_default() {
359
 extern "C" struct slop_options slop_options_default() {
347
     struct slop_options options;
360
     struct slop_options options;