-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
86 lines (69 loc) · 2.51 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
project(LittleEngine)
cmake_minimum_required(VERSION 3.12)
find_package(OpenGL REQUIRED)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
file(GLOB_RECURSE SRCS ${CMAKE_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HDRS ${CMAKE_SOURCE_DIR}/src/*.h)
file(GLOB_RECURSE HPPS ${CMAKE_SOURCE_DIR}/src/*.hpp)
add_subdirectory("ext/glfw")
add_subdirectory("ext/glad")
add_subdirectory("ext/glm/glm")
# DOWNLOAD ALL THE SUBMODULES
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
# CHECK ALL THE SUBMODULES
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/ext/glfw/CMakeLists.txt")
message(FATAL_ERROR "The glfw submodules was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/ext/glad/CMakeLists.txt")
message(FATAL_ERROR "The glad submodules was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/ext/glm/glm/CMakeLists.txt")
message(FATAL_ERROR "The glm submodules was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
# CHECK PYTHON FOR COMPILING GLAD
find_package(Python3 COMPONENTS Interpreter Development)
if(NOT PYTHON3_FOUND)
message(FATAL_ERROR "Python 3 interpreter not installed. Please download and install python to continue. See: https://www.python.org/downloads/")
endif()
set_directory_properties(PROPERTIES
VS_STARTUP_PROJECT "${PROJECT_NAME}"
)
add_library(lodepng
STATIC
"ext/lodepng/lodepng.cpp"
"ext/lodepng/lodepng.h"
)
add_executable("${PROJECT_NAME}"
"${SRCS}"
"${HDRS}"
"${HPPS}"
)
target_include_directories("${PROJECT_NAME}"
PUBLIC
"ext/glfw/include"
"ext/glad/include/glad"
"ext/glm"
"ext/lodepng"
"src"
)
target_link_libraries("${PROJECT_NAME}"
PUBLIC
glfw
glad
glm
lodepng
)