-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
117 lines (93 loc) · 3.11 KB
/
CMakeLists.txt
File metadata and controls
117 lines (93 loc) · 3.11 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.15)
# Valgrind profiling support
project(ProjecCpp)
set(SOURCES main.cpp)
#hello world
#testing branch
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external")
set(IMGUI_DIR "${LIB_DIR}/imgui")
set(GLM_LINK_FLAGS "-lm")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GLM_LINK_FLAGS}")
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(SDL2 REQUIRED)
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/source")
set(INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
########################################################
# GLAD library
#https://stackoverflow.com/questions/68014365/how-can-i-link-glfw-and-dear-imgui-in-cmake
########################################################
set(GLAD_DIR "${LIB_DIR}/glad")
add_library(glad "${GLAD_DIR}/src/glad.c")
target_include_directories(glad PUBLIC "${LIB_DIR}/glad/include")
########################################################
# Dear IMGUI library
########################################################
add_library(imgui
"${IMGUI_DIR}/imgui.cpp"
"${IMGUI_DIR}/imgui_demo.cpp"
"${IMGUI_DIR}/imgui_draw.cpp"
"${IMGUI_DIR}/imgui_tables.cpp"
"${IMGUI_DIR}/imgui_widgets.cpp"
"${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp"
"${IMGUI_DIR}/backends/imgui_impl_glfw.cpp"
)
target_include_directories(imgui PUBLIC
${IMGUI_DIR}
${IMGUI_DIR}/backends
${IMGUI_DIR}/
)
########################################################
# Creating a Common Libraries Interface
########################################################
add_library(common_libs INTERFACE)
target_link_libraries(common_libs INTERFACE
imgui
glad
glfw
glm::glm
SDL2::SDL2
)
target_include_directories(common_libs INTERFACE
${INC_DIR}
${SRC_DIR}
)
########################################################
# Create the main executable
########################################################
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE
imgui
glad
glfw
glm::glm
SDL2::SDL2
${CMAKE_DL_LIBS}
)
########################################################
# Samples for testing purposes
########################################################
set("SAMPLES_DIR" "${CMAKE_CURRENT_SOURCE_DIR}/samples")
# add_executable(imgui_sample "${SAMPLES_DIR}/imgui_sample.cpp")
# target_link_libraries(imgui_sample PRIVATE
# common_libs
# )
#add_executable(CorpSimulation "${SAMPLES_DIR}/CorpSimulation.cpp" )
#target_link_libraries(CorpSimulation PRIVATE
# common_libs
#)
# TwoBodyProblem sample
add_executable(TwoBodyProblem "${SAMPLES_DIR}/TwoBodyProblem.cpp")
target_link_libraries(TwoBodyProblem PRIVATE common_libs)
# NBodyProblem sample
add_executable(NBodyProblem "${SAMPLES_DIR}/NBodyProblem.cpp")
target_link_libraries(NBodyProblem PRIVATE common_libs)
# # SolarSystem sample
add_executable(SolarSystem "${SAMPLES_DIR}/SolarSystem.cpp")
target_link_libraries(SolarSystem PRIVATE common_libs)
# # sphere sample
# add_executable(sphere "${SAMPLES_DIR}/sphere.cpp")
# target_link_libraries(sphere PRIVATE common_libs)
# # sphericalsolsys sample
add_executable(sphericalsolsys "${SAMPLES_DIR}/sphericalsolsys.cpp")
target_link_libraries(sphericalsolsys PRIVATE common_libs)