-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (57 loc) · 1.85 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
# Get CMake PreDefined Variables https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
# This CMake File for OpenGL Projects is compiled by Kushagra
# I do not claim that this is the best CMake Configuration you will get but it does work.
cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)
project(physics)
# Clang deez nuts
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Include debug information
set(CMAKE_BUILD_TYPE Debug)
# Add all Header Files
file(GLOB_RECURSE HEADER_FILES
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/src/*.hpp
)
IF (WIN32)
# Windows libraries:
find_package(OpenGL REQUIRED)
set(LIBS glfw opengl32 glad glm)
file(GLOB_RECURSE SOURCE_FILES
${CMAKE_SOURCE_DIR}/src/*.cpp
# ${CMAKE_SOURCE_DIR}/platform/windows.cpp
)
ELSE()
# Linux libraries:
set(LIBS glfw X11 glad glm)
file(GLOB_RECURSE SOURCE_FILES
${CMAKE_SOURCE_DIR}/src/*.cpp
# ${CMAKE_SOURCE_DIR}/platform/linux.cpp
)
ENDIF()
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
if (CMAKE_COMPILER_IS_GNUCC)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
endif()
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
endif()
# Variables for Paths of External Libraries
set(GLFW_ROOT_DIR external/glfw)
set(GLAD_ROOT_DIR external/glad)
set(GLM_ROOT_DIR external/glm)
# Add the External Libraries / Files Directory
add_subdirectory(${GLFW_ROOT_DIR})
add_subdirectory(${GLAD_ROOT_DIR})
add_subdirectory(${GLM_ROOT_DIR})
target_include_directories(${PROJECT_NAME}
PUBLIC ${GLFW_ROOT_DIR}/include
PUBLIC ${GLAD_ROOT_DIR}/include/glad
PUBLIC ${GLM_ROOT_DIR}/include
PUBLIC include
)
target_link_directories(${PROJECT_NAME}
PRIVATE ${GLFW_ROOT_DIR}/src
PRIVATE ${GLAD_ROOT_DIR}/src
PRIVATE ${GLM_ROOT_DIR}/src
)
target_link_libraries(${PROJECT_NAME} ${LIBS})