naelstrof 7 лет назад
Родитель
Сommit
75e04cce02
2 измененных файлов: 65 добавлений и 52 удалений
  1. 64
    51
      CMakeLists.txt
  2. 1
    1
      README.md

+ 64
- 51
CMakeLists.txt Просмотреть файл

@@ -6,73 +6,86 @@ if ( NOT CMAKE_INSTALL_PREFIX )
6 6
 endif()
7 7
 
8 8
 if ( NOT SLOP_LEGACY_MODE )
9
-    set(SLOP_LEGACY_MODE FALSE CACHE BOOL "Legacy mode requires the XShape extension, is laggy, isn't guaranteed to be invisible on shutdown, isn't guaranteed to support opacity, doesn't support custom shaders, and requires C++11 for the sleep_for functions. Though it still might be desired since it doesn't require OpenGL to use.")
9
+    set(SLOP_LEGACY_MODE FALSE CACHE BOOL "Legacy mode requires the XShape extension, is laggy, isn't guaranteed to be invisible on shutdown, isn't guaranteed to support opacity, doesn't support custom shaders, and requires C++11 for the sleep_for functions. Though it still might be desired since it doesn't require OpenGL to use. Your choice <:o)")
10 10
 endif()
11 11
 
12 12
 project(slop)
13 13
 
14
-add_definitions(-DSLOP_VERSION="v5.3.21")
15
-if ( SLOP_LEGACY_MODE )
16
-    add_definitions(-DSLOP_LEGACY_MODE=true)
17
-endif()
18
-
19 14
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
20 15
 
21 16
 include_directories("${PROJECT_BINARY_DIR}")
22 17
 
23
-# Define sources and executable
24
-set(EXECUTABLE_NAME "slop")
18
+add_definitions(-DSLOP_VERSION="v5.3.21")
25 19
 
26
-set( source src/x.cpp
27
-            src/windowhelper.cpp
28
-            src/mouse.cpp
29
-            src/keyboard.cpp
30
-            src/resource.cpp
31
-            src/options.cpp
32
-            src/slopstates.cpp
33
-            src/main.cpp )
20
+# The names have to be unique unfortunately.
21
+set(EXECUTABLE_NAME "slop")
22
+set(LIBRARY_NAME "slopy")
23
+set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
34 24
 
35 25
 if ( SLOP_LEGACY_MODE )
36
-    set ( source ${source}
37
-                 src/xslop.cpp
38
-                 src/xshaperectangle.cpp )
39
-else()
40
-    set ( source ${source}
41
-                 src/window.cpp
42
-                 src/glslop.cpp
43
-                 src/rectangle.cpp
44
-                 src/framebuffer.cpp
45
-                 src/gl_core_3_3.c
46
-                 src/shader.cpp )
47
-endif()
48
-
49
-add_executable(${EXECUTABLE_NAME} ${source})
50
-
51
-# Detect and add cmake modules
52
-set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
53
-find_package(GLM REQUIRED)
54
-find_package(X11 REQUIRED)
26
+    add_definitions(-DSLOP_LEGACY_MODE=true)
27
+    add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
28
+                                        src/keyboard.cpp
29
+                                        src/x.cpp
30
+                                        src/slopstates.cpp
31
+                                        src/windowhelper.cpp
32
+                                        src/resource.cpp
33
+                                        src/xslop.cpp
34
+                                        src/xshaperectangle.cpp)
35
+    set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD 11)
36
+    set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
55 37
 
56
-include_directories(${X11_INCLUDE_DIR}
57
-                    ${GLM_INCLUDE_DIR})
58
-target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
59
-                                         ${GLM_LIBRARIES})
38
+    add_executable(${EXECUTABLE_NAME} src/options.cpp
39
+                                      src/main.cpp)
60 40
 
61
-# Either we require OpenGL, or we require the XShape extension.
62
-if ( SLOP_LEGACY_MODE )
41
+    # Detect and add cmake modules
42
+    find_package(GLM REQUIRED)
43
+    find_package(X11 REQUIRED)
63 44
     find_package(XExt REQUIRED)
64
-    include_directories(${XEXT_INCLUDE_DIR})
65
-    target_link_libraries(${EXECUTABLE_NAME} ${XEXT_LIBRARIES})
66
-    set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 11)
67
-    set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
45
+    include_directories(${X11_INCLUDE_DIR}
46
+                        ${GLM_INCLUDE_DIR}
47
+                        ${XEXT_INCLUDE_DIR})
48
+    target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
49
+                                             ${GLM_LIBRARIES}
50
+                                             ${XEXT_LIBRARIES}
51
+                                             ${LIBRARY_NAME})
52
+    # Install targets
53
+    install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
54
+    install( TARGETS ${LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
55
+    install( FILES ${CMAKE_SOURCE_DIR}/src/xslop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
68 56
 else()
57
+    add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
58
+                                        src/keyboard.cpp
59
+                                        src/x.cpp
60
+                                        src/slopstates.cpp
61
+                                        src/framebuffer.cpp
62
+                                        src/windowhelper.cpp
63
+                                        src/resource.cpp
64
+                                        src/gl_core_3_3.c
65
+                                        src/shader.cpp
66
+                                        src/window.cpp
67
+                                        src/glslop.cpp
68
+                                        src/rectangle.cpp)
69
+
70
+    add_executable(${EXECUTABLE_NAME} src/options.cpp
71
+                                      src/main.cpp)
72
+
73
+    # Detect and add cmake modules
74
+    find_package(GLM REQUIRED)
75
+    find_package(X11 REQUIRED)
69 76
     find_package(GLX REQUIRED)
70 77
     find_package(OpenGL REQUIRED)
71
-    include_directories(${GLX_INCLUDE_DIR}
78
+    include_directories(${X11_INCLUDE_DIR}
79
+                        ${GLM_INCLUDE_DIR}
80
+                        ${GLX_INCLUDE_DIR}
72 81
                         ${OPENGL_INCLUDE_DIR})
73
-    target_link_libraries(${EXECUTABLE_NAME} ${OPENGL_LIBRARIES}
74
-                                             ${GLX_LIBRARY})
82
+    target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
83
+                                             ${GLM_LIBRARIES}
84
+                                             ${OPENGL_LIBRARIES}
85
+                                             ${GLX_LIBRARY}
86
+                                             ${LIBRARY_NAME})
87
+    # Install targets
88
+    install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
89
+    install( TARGETS ${LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
90
+    install( FILES ${CMAKE_SOURCE_DIR}/src/glslop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
75 91
 endif()
76
-
77
-# Install targets
78
-install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )

+ 1
- 1
README.md Просмотреть файл

@@ -15,7 +15,7 @@ TODO:
15 15
 - [x] Mouse stuff
16 16
 - [x] Drawing stuff
17 17
 - [x] Printing stuff
18
-- [ ] Librarify (so I can plug it into maim)
18
+- [x] Librarify
19 19
 
20 20
 Avoiding:
21 21
 - [ ] Themes (Not going to happen. It'd add a texture library dependency.)