-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
173 lines (125 loc) · 4.22 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
project(fw)
set(CMAKE_MIN_VERSION 2.8)
cmake_minimum_required(VERSION ${CMAKE_MIN_VERSION} FATAL_ERROR)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
SET(CMAKE_CXX_FLAGS "-std=c++11")
# set(CMAKE_BUILD_TYPE Release)
if (CMAKE_BUILD_TYPE MATCHES Release)
message(STATUS "fw target is Release")
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "fw target is Debug")
else()
message(STATUS "fw target is default, using Debug")
set(CMAKE_BUILD_TYPE Debug)
endif()
add_definitions(-Wall)
add_definitions(-DPROJECT_ROOT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/lib/Release)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/lib/Release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/lib/Debug)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/lib/Debug)
if (UNIX)
set(_SP_X11 1)
else()
message(FATAL_ERROR "Unsupported target platform")
endif()
### MODELS (download and extract from internet)
set(MODEL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/assets/models)
set(MODELS
# ${MODEL_DIR}/dragon
)
set(MODEL_URLS
# http://graphics.cs.williams.edu/data/meshes/dragon.zip
)
list(LENGTH MODEL_URLS n_urls)
math(EXPR max_i "${n_urls} - 1")
foreach(i RANGE ${max_i})
list(GET MODELS ${i} model)
list(GET MODEL_URLS ${i} model_url)
add_custom_command(
OUTPUT ${model}
COMMAND wget -O ${model}.zip ${model_url}
COMMAND unzip -d ${model} ${model}.zip
COMMAND rm ${model}.zip
)
endforeach()
### END MODELS
set(EXT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ext)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "")
set(GLFW_BUILD_TESTS OFF CACHE BOOL "")
set(GLFW_INSTALL OFF CACHE BOOL "")
add_subdirectory(${EXT_PATH}/glfw)
find_package(OpenGL REQUIRED)
include(FindOpenAL)
include(cmake-modules/FindALUT.cmake)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${EXT_PATH}
${EXT_PATH}/glfw/include
${EXT_PATH}/glew-cmake/include
${EXT_PATH}/glm
${EXT_PATH}/conglomerate/include
${EXT_PATH}/assimp/include
${EXT_PATH}/Simple-OpenGL-Image-Library/src
${EXT_PATH}/imgui
${OPENGL_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${ALUT_INCLUDE_DIR}
)
add_subdirectory(${EXT_PATH}/conglomerate)
set(glew-cmake_BUILD_SHARED OFF)
set(glew-cmake_BUILD_STATIC ON)
add_subdirectory(${EXT_PATH}/glew-cmake/build/cmake)
set(ASSIMP_BUILD_TESTS OFF)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF)
set(ASSIMP_BUILD_SAMPLES OFF)
set(ASSIMP_INSTALL_PDB OFF)
add_subdirectory(${EXT_PATH}/assimp)
add_subdirectory(${EXT_PATH}/Simple-OpenGL-Image-Library)
#
# add_subdirectory(${EXT_PATH}/alure)
file(GLOB ImGui_sources ${EXT_PATH}/imgui/*.cpp)
add_library(ImGui STATIC ${ImGui_sources})
target_link_libraries(ImGui GL glfw glew_s ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES})
file(GLOB_RECURSE all_shaders
${CMAKE_CURRENT_SOURCE_DIR}/src/*.glsl
${CMAKE_CURRENT_SOURCE_DIR}/src/*.vert
${CMAKE_CURRENT_SOURCE_DIR}/src/*.tesc
${CMAKE_CURRENT_SOURCE_DIR}/src/*.tese
${CMAKE_CURRENT_SOURCE_DIR}/src/*.geom
${CMAKE_CURRENT_SOURCE_DIR}/src/*.frag
${CMAKE_CURRENT_SOURCE_DIR}/src/*.comp)
list(REMOVE_DUPLICATES all_shaders)
set(PROJECT_LIB fworks)
set(PROJECT_EXE fireworks)
set(PROJECT_MAIN_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp)
file(GLOB_RECURSE all_sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
list(REMOVE_DUPLICATES all_sources)
list(REMOVE_ITEM all_sources ${PROJECT_MAIN_CC})
file(GLOB_RECURSE all_headers ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp)
list(REMOVE_DUPLICATES all_headers)
set(EXT_LIBS
GL
pthread
${OPENGL_LIBRARIES}
glew_s
glfw
${GLFW_LIBRARIES}
glomerate
assimp
SOIL
ImGui
${OPENAL_LIBRARY}
${ALUT_LIBRARIES}
# alure2_s
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
add_library(${PROJECT_LIB} ${all_sources} ${all_headers} ${all_shaders})
target_link_libraries(${PROJECT_LIB} ${EXT_LIBS})
add_executable(${PROJECT_EXE} ${PROJECT_MAIN_CC} ${MODELS})
target_link_libraries(${PROJECT_EXE} ${PROJECT_LIB})