forked from hacktheegg/glThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (62 loc) · 1.77 KB
/
CMakeLists.txt
File metadata and controls
75 lines (62 loc) · 1.77 KB
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
cmake_minimum_required(VERSION 3.10)
project(glThings)
# Create GLAD library directly
add_library(glad STATIC
"${PROJECT_SOURCE_DIR}/dep/glad/src/glad.c"
"${PROJECT_SOURCE_DIR}/dep/glad/include/glad/glad.h"
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set include directory for GLAD
target_include_directories(glad PUBLIC
"${PROJECT_SOURCE_DIR}/dep/glad/include"
)
# Add GLFW subdirectory
add_subdirectory("${PROJECT_SOURCE_DIR}/dep/glfw")
# Add GLM subdirectory
add_subdirectory("${PROJECT_SOURCE_DIR}/dep/glm")
# Define source and header files
set(SOURCES
"${PROJECT_SOURCE_DIR}/src/main.cpp"
)
set(HEADERS
"${PROJECT_SOURCE_DIR}/src/physSolver.hpp"
"${PROJECT_SOURCE_DIR}/src/renderer.hpp"
"${PROJECT_SOURCE_DIR}/src/shader_s.hpp"
)
# Check if this is the top-level project
if(PROJECT_IS_TOP_LEVEL)
# Build as executable
add_executable(glThings ${SOURCES} ${HEADERS})
# Link all dependencies
target_link_libraries(glThings
PRIVATE glad
PRIVATE glfw
PRIVATE glm::glm
)
# Set include directories
target_include_directories(glThings PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/dep/glad/include
${PROJECT_SOURCE_DIR}/dep/glfw/include
${PROJECT_SOURCE_DIR}/dep/glm
)
else()
# Build as library
add_library(glThings STATIC
${SOURCES}
${HEADERS}
)
# Link all dependencies
target_link_libraries(glThings
PRIVATE glad
PRIVATE glfw
PRIVATE glm::glm
)
# Set include directories
target_include_directories(glThings PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/dep/glad/include
${PROJECT_SOURCE_DIR}/dep/glfw/include
${PROJECT_SOURCE_DIR}/dep/glm
)
endif()