generated from Hoshiningen/OpenGL-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (67 loc) · 3.45 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
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
include(CMakePrintHelpers)
project(Gragzo CXX)
#===========================================================================================
# OPTIONAL LIBRARiES
#
# The following libraries can be pulled down and added to the project by turnning the
# desired options on. Open an issue for additional default support.
# See: https://github.com/Hoshiningen/OpenGL-Template/issues
set(ENABLE_ASSIMP OFF CACHE BOOL "Add Open Asset Import Library (assimp) to the project" FORCE)
set(exe_name "run")
#===========================================================================================
# GLAD CONFIGURATION
#
# Configure GLAD loader generation variables (lines below pulled from the GLAD top-level
# CMakeLists.txt file, with slight modifications.
# Refer to https://github.com/Dav1dde/glad for more information)
set(GLAD_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "Output directory" FORCE)
set(GLAD_PROFILE "core" CACHE STRING "OpenGL profile" FORCE)
set(GLAD_API "gl=3.3" CACHE STRING "API type/version pairs, like \"gl=3.2,gles=\", no version means latest" FORCE)
set(GLAD_GENERATOR "c" CACHE STRING "Language to generate the binding for" FORCE)
set(GLAD_EXTENSIONS "" CACHE STRING "Path to extensions file or comma separated list of extensions, if missing all extensions are included" FORCE)
set(GLAD_SPEC "gl" CACHE STRING "Name of the spec" FORCE)
set(GLAD_ALL_EXTENSIONS OFF CACHE BOOL "Include all extensions instead of those specified by GLAD_EXTENSIONS" FORCE)
set(GLAD_NO_LOADER OFF CACHE BOOL "No loader" FORCE)
set(GLAD_REPRODUCIBLE OFF CACHE BOOL "Reproducible build" FORCE)
#===========================================================================================
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Set directory paths
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# set(sources ${SOURCE_DIR}/main.cpp)
# set(sources ${SOURCE_DIR}/utils.cpp)
file(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} source/*.cpp include/*.hpp include/*.h include/external/imgui/*.h include/external/stb/*.h)
# file(GLOB_RECURSE includes RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/*.h")
# include_directories(${INCLUDE_DIR})
# cmake_print_variables(sources)
add_executable(${exe_name} ${sources})
target_include_directories(${exe_name} PUBLIC ${INCLUDE_DIR} PUBLIC ${INCLUDE_DIR}/external ${INCLUDE_DIR}/external/imgui ${INCLUDE_DIR}/external/stb)
# Perform dependency linkage
include(${CMAKE_DIR}/LinkGLFW.cmake)
LinkGLFW(${exe_name} PRIVATE)
include(${CMAKE_DIR}/LinkGLM.cmake)
LinkGLM(${exe_name} PRIVATE)
include(${CMAKE_DIR}/LinkGLAD.cmake)
LinkGLAD(${exe_name} PRIVATE)
find_package(OpenGL REQUIRED)
if (OpenGL_FOUND)
target_include_directories(${exe_name} PRIVATE ${OPENGL_INCLDUE_DIRS})
target_link_libraries(${exe_name} PRIVATE ${OPENGL_LIBRARIES})
else()
message(FATAL_ERROR "OpenGL was not found on the system")
endif()
# Handle the optional libraries
# if (${ENABLE_ASSIMP})
# include(${CMAKE_DIR}/LinkASSIMP.cmake)
# LinkASSIMP(${exe_name} PRIVATE)
# endif()
# Enable C++17
set_target_properties(${exe_name} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
# Set project folders
set_target_properties(${exe_name} PROPERTIES FOLDER ${PROJECT_NAME})