1
- cmake_minimum_required (VERSION 2.8)
2
- project (GraphicsEngine)
3
- set (CMAKE_CXX_STANDARD 17)
1
+ cmake_minimum_required (VERSION 3.2)
2
+
4
3
5
4
6
5
###
7
6
### Options
8
7
###
9
8
# Unsed previous parameters from cache for the sake of dynamism
10
- unset (GRAPHICSENGINE_SUPPORT_GLFW CACHE )
11
- unset (GRAPHICSENGINE_SUPPORT_GLAD CACHE )
12
- unset (GRAPHICSENGINE_SUPPORT_GLEW CACHE )
13
9
unset (GRAPHICSENGINE_SUPPORT_GLM CACHE )
14
10
unset (GRAPHICSENGINE_SUPPORT_OPENSSL CACHE )
11
+ unset (GRAPHICSENGINE_SUPPORT_VULKAN CACHE )
12
+ unset (GRAPHICSENGINE_SUPPORT_TASKUS CACHE )
13
+ unset (GRAPHICSENGINE_USE_VCPKG CACHE )
14
+
15
15
16
16
# Enable desired libs
17
- option (GRAPHICSENGINE_SUPPORT_GLFW "Set ON/OFF to enable/disable GLFW support. " ON )
18
- option (GRAPHICSENGINE_SUPPORT_GLAD "Set ON/OFF to enable/disable GLAD support." ON )
19
- option (GRAPHICSENGINE_SUPPORT_GLEW "Set ON/OFF to enable/disable GLEW support." ON )
20
- option (GRAPHICSENGINE_SUPPORT_GLM "Set ON/OFF to enable/disable GLM support. " ON )
21
- option (GRAPHICSENGINE_SUPPORT_OPENSSL "Set ON/OFF to enable/disable OpenSLL support. " ON )
17
+ option (GRAPHICSENGINE_SUPPORT_GLM "Set ON/OFF to enable/disable GLM support" ON )
18
+ option (GRAPHICSENGINE_SUPPORT_OPENSSL "Set ON/OFF to enable/disable OpenSSL support." ON )
19
+ option (GRAPHICSENGINE_SUPPORT_VULKAN "Set ON/OFF to enable/disable Vulkan support." ON )
20
+ option (GRAPHICSENGINE_SUPPORT_TASKUS "Set ON/OFF to enable/disable Taskus support" ON )
21
+ option (GRAPHICSENGINE_USE_VCPKG "Use VCPKG in Windows " ON )
22
22
23
+ if (WIN32 )
24
+ if (GRAPHICSENGINE_USE_VCPKG)
25
+ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
26
+ #use my own path in cmake_toolchain_file
27
+ #you should replace this on your machine or specify it as a argument while configurng
28
+ set (CMAKE_TOOLCHAIN_FILE "C:/dev-bin/vcpkg/scripts/buildsystems/vcpkg.cmake" )
29
+ endif ()
30
+ endif ()
31
+
32
+ endif ()
33
+
34
+ project (GraphicsEngine)
35
+ set (CMAKE_CXX_STANDARD 20)
23
36
24
37
###
25
38
### Initialization
26
39
###
27
40
# Project parameters
28
41
set (PROJ_LINK_LIBS)
29
42
set (PROJ_SRC)
30
- find_library ( atomic-lib atomic )
31
- list (APPEND PROJ_LINK_LIBS atomic)
43
+ set (PROJ_SHADERS)
44
+ if (NOT WIN32 )
45
+ find_library ( atomic-lib atomic )
46
+ list (APPEND PROJ_LINK_LIBS atomic)
47
+ endif ()
32
48
if (WIN32 )
33
- set (CMAKE_RC_COMPILER "windres" ) #Windows only, for some reason mys2 mingw 64 gets the rc compiler wrong
49
+ # set(CMAKE_RC_COMPILER "windres") #Windows only, for some reason mys2 mingw 64 gets the rc compiler wrong
34
50
find_package (OpenGL REQUIRED)
35
51
36
52
list (APPEND PROJ_LINK_LIBS opengl32)
37
53
endif (WIN32 )
38
54
39
55
# Add all files/folders under src folder automatically to the project
40
- file (GLOB_RECURSE PROJ_SRC src/*.h src/*.cpp)
41
-
56
+ file (GLOB_RECURSE PROJ_SRC_CPP src/*.cpp)
57
+ file (GLOB_RECURSE PROJ_SRC_H src/*.h)
58
+ file (GLOB PROJ_SHADERS src/shaders/*.vert src/shaders/*.frag)
42
59
43
60
###
44
61
### Compiler settings
45
62
###
46
63
47
64
48
-
49
65
###
50
- ### GLFW
66
+ ### Taskus
51
67
###
52
- if (GRAPHICSENGINE_SUPPORT_GLFW)
53
- # Disable internal builds
54
- unset (GLFW_BUILD_EXAMPLES CACHE )
55
- unset (GLFW_BUILD_TESTS CACHE )
56
- unset (GLFW_BUILD_DOCS CACHE )
57
- option (GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF )
58
- option (GLFW_BUILD_TESTS "Build the GLFW test programs" OFF )
59
- option (GLFW_BUILD_DOCS "Build the GLFW documentation" OFF )
60
-
61
- add_subdirectory (libs/glfw)
62
- list (APPEND PROJ_LINK_LIBS glfw)
63
- endif (GRAPHICSENGINE_SUPPORT_GLFW)
64
68
69
+ #MINGW IS NOT SUPPORTED BECAUSE OF TASKUS
70
+ if (GRAPHICSENGINE_SUPPORT_TASKUS)
71
+ add_subdirectory (libs/Taskus)
72
+ list (APPEND PROJ_LINK_LIBS Taskus)
73
+ endif ()
65
74
66
- ###
67
- ### GLAD
68
- ###
69
- if (GRAPHICSENGINE_SUPPORT_GLAD)
70
- include_directories (libs/glfw/deps)
71
- endif (GRAPHICSENGINE_SUPPORT_GLAD)
72
75
73
76
74
- ###
75
- ### GLEW
76
- ###
77
- if (GRAPHICSENGINE_SUPPORT_GLEW)
78
- # Disable internal builds
79
- unset (BUILD_UTILS CACHE )
80
- option (BUILD_UTILS "utilities" OFF )
81
77
82
- add_subdirectory (libs/glew/build /cmake)
83
- include_directories (libs/glew/include )
84
- list (APPEND PROJ_LINK_LIBS glew)
85
- endif (GRAPHICSENGINE_SUPPORT_GLEW)
86
78
87
79
###
88
80
### GLM
@@ -96,19 +88,50 @@ endif(GRAPHICSENGINE_SUPPORT_GLM)
96
88
### OpenSSL
97
89
###
98
90
if (GRAPHICSENGINE_SUPPORT_OPENSSL)
99
- find_package (OpenSSL)
91
+ find_package (OpenSSL REQUIRED )
100
92
list (APPEND PROJ_LINK_LIBS OpenSSL::SSL)
101
93
list (APPEND PROJ_LINK_LIBS OpenSSL::Crypto)
102
94
endif (GRAPHICSENGINE_SUPPORT_OPENSSL)
103
95
96
+ ###
97
+ ### Vulkan
98
+ ###
99
+
100
+ if (GRAPHICSENGINE_SUPPORT_VULKAN)
101
+ if (WIN32 )
102
+ set (ENV{VULKAN_SDK} "C:\\ VulkanSDK\\ 1.2.198.1" ) #default installation for vulkansdk in windows
103
+ endif (WIN32 )
104
+
105
+ find_package (Vulkan REQUIRED)
106
+ list (APPEND PROJ_LINK_LIBS ${Vulkan_LIBRARIES} )
107
+ include_directories (${Vulkan_INCLUDE_DIRS} )
108
+ endif (GRAPHICSENGINE_SUPPORT_VULKAN)
109
+
110
+
111
+
112
+
113
+ ### Compile the shaders after building the source
114
+
115
+ foreach (shader ${PROJ_SHADERS} )
116
+ set (SHADER_FILENAME)
117
+
118
+ cmake_path(GET shader FILENAME SHADER_FILENAME)
119
+ message (STATUS "Adding shader to compile: " ${SHADER_FILENAME} )
120
+ set (COMMAND_TO_EXECUTE ${Vulkan_GLSLC_EXECUTABLE} ${shader} -o ${SHADER_FILENAME} .spv)
121
+ add_custom_target (${SHADER_FILENAME} ALL
122
+ COMMAND ${COMMAND_TO_EXECUTE} )
123
+
124
+ endforeach ()
104
125
105
126
###
106
127
### Generating the project files
107
128
###
108
- add_executable (${PROJECT_NAME} ${PROJ_SRC } )
129
+ add_executable (${PROJECT_NAME} ${PROJ_SRC_CPP} ${PROJ_SRC_H } )
109
130
110
131
111
132
###
112
133
### Linking to the project
113
134
###
114
135
target_link_libraries (${PROJECT_NAME} ${PROJ_LINK_LIBS} )
136
+
137
+
0 commit comments