-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
98 lines (60 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
87
88
89
90
91
92
93
94
95
96
97
98
#https://github.com/meemknight/cmakeSetup
#Version 1.0.0
cmake_minimum_required(VERSION 3.16)
#set this to true to ship the game!
#! ! ! ! ! ! !
#DELETE THE OUT FOLDER AFTER CHANGING THIS BECAUSE VISUAL STUDIO DOESN'T SEEM TO RECOGNIZE THIS CHANGE AND REBUILD!
option(PRODUCTION_BUILD "Make this a production build" OFF)
#DELETE THE OUT FOLDER AFTER CHANGING THIS BECAUSE VISUAL STUDIO DOESN'T SEEM TO RECOGNIZE THIS CHANGE AND REBUILD!
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
endif()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) #link time optimization
project(gl3dDev)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/glfw-3.3.2) #window oppener
add_subdirectory(thirdparty/glad) #opengl loader
add_subdirectory(thirdparty/stb_image) #loading immaged
add_subdirectory(thirdparty/glm) #math
add_subdirectory(thirdparty/imgui-docking) #ui
# Define MY_SOURCES to be a list of all the source files for my game
file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_executable("${CMAKE_PROJECT_NAME}")
set_property(TARGET "${CMAKE_PROJECT_NAME}" PROPERTY CXX_STANDARD 17)
if(PRODUCTION_BUILD)
# setup the ASSETS_PATH macro to be in the root folder of your exe
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="./resources/")
# remove the option to debug asserts.
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC PRODUCTION_BUILD=1)
else()
# This is useful to get an ASSETS_PATH in your IDE during development
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/")
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC SHADERS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/src/shaders/")
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC PRODUCTION_BUILD=0)
endif()
target_sources("${CMAKE_PROJECT_NAME}" PRIVATE ${MY_SOURCES} )
if(MSVC) # If using the VS compiler...
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC _CRT_SECURE_NO_WARNINGS)
set_target_properties("${CMAKE_PROJECT_NAME}" PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") #no console
endif()
target_include_directories("${CMAKE_PROJECT_NAME}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}//src/")
target_include_directories("${CMAKE_PROJECT_NAME}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}//src/src/")
target_link_libraries("${CMAKE_PROJECT_NAME}" PRIVATE glm glfw
glad stb_image imgui)
project(simpleDemo)
add_subdirectory(headerOnly)
add_executable("simpleDemo")
set_property(TARGET simpleDemo PROPERTY CXX_STANDARD 17)
target_sources(simpleDemo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}"/simpleDemo/mainDemo.cpp" )
target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/")
if(MSVC) # If using the VS compiler...
target_compile_definitions(simpleDemo PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()
target_link_libraries("${CMAKE_PROJECT_NAME}" PRIVATE glm glfw gl3d
glad stb_image imgui)