-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
102 lines (85 loc) · 2.09 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.10)
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
project(GraphicsAPI VERSION 1.0)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type Debug as none was specified")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Default build type." FORCE)
endif()
# database for YCM:
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set(OpenGL_PROFILE GLFW_OPENGL_CORE_PROFILE)
set(OpenGL_VERSION_MAJOR 4)
set(OpenGL_VERSION_MINOR 3)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-OgWall")
set(CMAKE_C_FLAGS_DEBUG_INIT "-OgWall")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3Wall")
set(CMAKE_C_FLAGS_RELEASE_INIT "-O3Wall")
configure_file(
"${PROJECT_SOURCE_DIR}/headers/OpenGLVersion.hpp.in"
"${PROJECT_BINARY_DIR}/OpenGLVersion.hpp"
)
include_directories("${PROJECT_BINARY_DIR}")
set(CMAKE_C_COMPILER "g++" CACHE STRING "C compiler")
set(CMAKE_CXX_COMPILER "g++" CACHE STRING "CXX compiler")
add_executable(
executable
main.cpp
textures/texture.cpp
shaders/program.cpp shaders/light.cpp shaders/material.cpp
models/model.cpp models/cube.cpp
window/window.cpp window/camera.cpp
debug/debug.cpp
)
if(UNIX AND NOT APPLE)
target_link_libraries(
executable
dl.so
pthread.so
)
set_target_properties(
executable
PROPERTIES
OUTPUT_NAME "run.out"
)
elseif(WIN32)
target_link_libraries(
executable
opengl32.dll
gdi32.dll
user32.dll
kernel32.dll
)
set_target_properties(
executable
PROPERTIES
OUTPUT_NAME "run"
)
endif()
#glfw
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory("libraries/src/glfw")
#glad
add_library(glad STATIC "libraries/src/glad/glad.c")
target_include_directories(glad PRIVATE "libraries/includes")
target_link_libraries(
executable
glfw
glad
)
set_target_properties(
glfw glad
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/libraries/lib"
)
#includes
target_include_directories(executable
PUBLIC libraries/includes
PUBLIC headers
)
set_target_properties(
executable
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}"
)