-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
86 lines (74 loc) · 3.24 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
cmake_minimum_required(VERSION 3.10)
project(crumble)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
#---------------------------------------------
# Detect the Host OS
#---------------------------------------------
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
message(STATUS "Host system name: ${CMAKE_HOST_SYSTEM_NAME}")
endif()
#---------------------------------------------
# Add Include Directories
#
# Include the directories to the list of paths
# that the compiler uses to search for include
# files. Include parent directory if you want
# includes that look like <GLFW/glfw3.h>
#---------------------------------------------
include_directories(crumble ./src ./vendor ./vendor/glfw3/include/ ./vendor/imgui/ ./vendor/imgui/backends/)
#---------------------------------------------
# Find OpenGL
#---------------------------------------------
set(OPENGL_WINDOWS_PATH "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64")
find_library(OPENGL_STATIC_LIBRARY NAMES OpenGL32 OpenGL32.Lib opengl32 OpenGL openGL32 HINTS ${OPENGL_WINDOWS_PATH})
find_file(OPENGL_DYNAMIC_LIBRARY opengl32.dll)
if (OPENGL_STATIC_LIBRARY)
message(STATUS "Found the OpenGL static library: ${OPENGL_STATIC_LIBRARY}")
elseif(OPENGL_DYNAMIC_LIBRARY)
message(STATUS "Found OpenGL windows dynamic library: ${OPENGL_DYNAMIC_LIBRARY}")
else()
message(STATUS "Could not find the dynamic OpenGL library")
message(STATUS "Could not find the static OpenGL library")
endif()
#---------------------------------------------
# Find GLFW
#---------------------------------------------
find_library(GLFW_LIBRARY NAMES glfw glfw3)
if (GLFW_LIBRARY)
message(STATUS "Found the GLFW library: ${GLFW_LIBRARY}")
else()
message(STATUS "Could not find the GLFW library")
endif()
#---------------------------------------------
# Find MacOS Specific Libraries
#---------------------------------------------
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
find_library(COCOA_LIBRARY Cocoa)
find_library(IO_LIBRARY IOKIT)
if (COCOA_LIBRARY AND IO_LIBRARY)
message(STATUS "Found the MacOS Specific Libraries")
else()
message(STATUS "Could not find the MacOS Specific Libraries")
endif()
endif()
#---------------------------------------------
# Create the Executable
#---------------------------------------------
add_executable(
crumble
./src/main.cpp ./src/glfw_wrapper.cpp ./src/imgui_wrapper.cpp ./src/gl_objects.cpp ./src/grid.cpp ./src/particle.cpp ./src/particle_system.cpp ./src/timer.cpp
./vendor/glad/glad.c
./vendor/imgui/imgui.cpp ./vendor/imgui/imgui_draw.cpp ./vendor/imgui/imgui_tables.cpp ./vendor/imgui/imgui_widgets.cpp ./vendor/imgui/imgui_demo.cpp
./vendor/imgui/backends/imgui_impl_opengl3.cpp ./vendor/imgui/backends/imgui_impl_glfw.cpp
)
#---------------------------------------------
# Link the Libraries
#---------------------------------------------
target_link_libraries(crumble ${GLFW_LIBRARY})
target_link_libraries(crumble ${OPENGL_STATIC_LIBRARY})
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
target_link_libraries(crumble ${COCOA_LIBRARY})
target_link_libraries(crumble ${IO_LIBRARY})
endif()