-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
135 lines (122 loc) · 3.86 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Specify minimum CMake version and project name
#
cmake_minimum_required(VERSION 3.6)
project (glowbox)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # nice for language servers
#
# Set python cmd, preferring python 3
#
find_program(PYTHON_3_LOCATION py)
if(NOT "${PYTHON_3_LOCATION}" STREQUAL "PYTHON_3_LOCATION-NOTFOUND") # windows shim
execute_process(COMMAND py -3 --version RESULT_VARIABLE has_python_3)
if("${has_python_3}" STREQUAL "0")
set (PYTHON_CMD py -3)
else()
set (PYTHON_CMD py) # may use python 2
endif()
else()
find_program(PYTHON_3_LOCATION python3)
if(NOT "${PYTHON_3_LOCATION}" STREQUAL "PYTHON_3_LOCATION-NOTFOUND") # windows shim
set (PYTHON_CMD python3)
else()
set (PYTHON_CMD python)
endif()
endif()
message("spis meg ${PYTHON_CMD}")
#
# CMake setup
#
set (CMAKE_CXX_STANDARD 14)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set (CMAKE_VERBOSE_MAKEFILE 0) # 1 should be used for debugging
set (CMAKE_SUPPRESS_REGENERATION TRUE) # Suppresses ZERO_CHECK
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
if(NOT WIN32)
set(GLAD_LIBRARIES dl)
endif()
endif()
#
# GLFW options
#
option (GLFW_INSTALL OFF)
option (GLFW_BUILD_DOCS OFF)
option (GLFW_BUILD_EXAMPLES OFF)
option (GLFW_BUILD_TESTS OFF)
add_subdirectory (lib/glfw)
# SFML options
# We only need sound for this project, so everything else can be turned off
option (SFML_BUILD_GRAPHICS OFF)
option (SFML_BUILD_WINDOW OFF)
option (SFML_BUILD_NETWORK OFF)
add_subdirectory(lib/SFML)
#
# Add FMT
#
add_subdirectory (lib/fmt)
#
# GLAD
#
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/glad/include)
message("Generating glad library files, using ${PYTHON_CMD}")
execute_process(
COMMAND ${PYTHON_CMD} -m glad --profile core --out-path . --generator c --spec gl
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/glad
)
message("Finished generating glad library files")
endif()
#
# Set include paths
#
include_directories (src/
lib/glad/include/
lib/glfw/include/
lib/lodepng/
lib/glm/
lib/stb/
lib/arrrgh/
lib/SFML/include/)
#
# Add files
#
file (GLOB VENDORS_SOURCES lib/glad/src/glad.c
lib/lodepng/lodepng.cpp)
file (GLOB_RECURSE PROJECT_HEADERS src/*.hpp
src/*.h)
file (GLOB_RECURSE PROJECT_SOURCES src/*.cpp
src/*.cxx
src/*.cc
src/*.c)
file (GLOB_RECURSE PROJECT_SHADERS res/shaders/*.comp
res/shaders/*.frag
res/shaders/*.geom
res/shaders/*.vert)
file (GLOB PROJECT_CONFIGS CMakeLists.txt
README.rst
.gitignore
.gitmodules)
#
# Organizing files
#
source_group ("headers" FILES ${PROJECT_HEADERS})
source_group ("shaders" FILES ${PROJECT_SHADERS})
source_group ("sources" FILES ${PROJECT_SOURCES})
source_group ("libraries" FILES ${VENDORS_SOURCES})
#
# Set executable and target link libraries
#
add_definitions (-DGLFW_INCLUDE_NONE
-DPROJECT_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\")
add_executable (${PROJECT_NAME} ${PROJECT_SOURCES} ${PROJECT_HEADERS}
${PROJECT_SHADERS} ${PROJECT_CONFIGS}
${VENDORS_SOURCES})
target_link_libraries (${PROJECT_NAME}
glfw
sfml-audio
fmt::fmt
${GLFW_LIBRARIES}
${GLAD_LIBRARIES})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT glowbox)