-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
111 lines (90 loc) · 3.25 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
cmake_minimum_required( VERSION 3.16 )
project( SWater )
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
## C++14 is okay here, could prolly work in C++11 too
set( CMAKE_CXX_STANDARD 14 )
## I have a habit of setting a root variable cuz' I'm lazy to type CMAKE_CURRENT_SOURCE_DIR every time
## In projects like these, which aren't meant to be used as dependencies, I prefix stuff with THE_,
## cuz' it's THE stuff, there won't be any other
set( THE_ROOT ${CMAKE_CURRENT_SOURCE_DIR} )
## Set up SDL2, OpenGL, glew, glm, stb_image and ImGui
## SDL2
if( UNIX )
find_package( SDL2 REQUIRED )
elseif( WIN32 )
## Note that I've only included 64-bit SDL2 binaries
set( SDL2_INCLUDE_DIRS
${THE_ROOT}/extern/SDL2/include )
set( SDL2_LIBRARIES
${THE_ROOT}/extern/SDL2/lib/SDL2.lib
${THE_ROOT}/extern/SDL2/lib/SDL2main.lib )
else()
message( FATAL_ERROR "This platform is not supported" )
endif()
## OpenGL
find_package( OpenGL REQUIRED )
if ( WIN32 )
set( OPENGL_LIBRARIES opengl32.lib )
elseif( UNIX )
set( OPENGL_LIBRARIES GL )
endif()
## glew
set( GLEW_INCLUDE_DIR
${THE_ROOT}/extern/glew/include )
set( GLEW_SOURCES
${THE_ROOT}/extern/glew/src/glew.c )
## stb_image
set( STB_IMAGE_INCLUDE_DIR
${THE_ROOT}/extern/stb_image )
## ImGui
set( IMGUI_INCLUDE_DIR
${THE_ROOT}/extern/imgui )
set( IMGUI_SOURCES
${THE_ROOT}/extern/imgui/imconfig.h
${THE_ROOT}/extern/imgui/imgui.cpp
${THE_ROOT}/extern/imgui/imgui.h
${THE_ROOT}/extern/imgui/imgui_draw.cpp
${THE_ROOT}/extern/imgui/imgui_tables.cpp
${THE_ROOT}/extern/imgui/imgui_widgets.cpp
${THE_ROOT}/extern/imgui/imstb_rectpack.h
${THE_ROOT}/extern/imgui/imstb_textedit.h
${THE_ROOT}/extern/imgui/imstb_truetype.h
${THE_ROOT}/extern/imgui/backends/imgui_impl_opengl3_loader.h
${THE_ROOT}/extern/imgui/backends/imgui_impl_opengl3.cpp
${THE_ROOT}/extern/imgui/backends/imgui_impl_opengl3.h
${THE_ROOT}/extern/imgui/backends/imgui_impl_sdl.cpp
${THE_ROOT}/extern/imgui/backends/imgui_impl_sdl.h )
## Set up our main thing
set( THE_SOURCES
${THE_ROOT}/src/Main.cpp
${THE_ROOT}/src/IApp.hpp
${THE_ROOT}/src/App.hpp
${THE_ROOT}/src/App.cpp
${THE_ROOT}/src/TextureProvider.hpp
${THE_ROOT}/src/TextureProvider.cpp
${GLEW_SOURCES} ## glew will be built into this directly
${IMGUI_SOURCES} ## and ImGui
)
## Folder organisation
source_group( TREE ${THE_ROOT} FILES ${THE_SOURCES} )
## The .exe
add_executable( SWater ${THE_SOURCES} )
## Include dirs
target_include_directories( SWater PRIVATE
${THE_ROOT}
${SDL2_INCLUDE_DIRS}
${GLEW_INCLUDE_DIR}
${IMGUI_INCLUDE_DIR}
${STB_IMAGE_INCLUDE_DIR} )
## Link against SDL2 libs
target_link_libraries( SWater PRIVATE ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} )
## Output here
install( TARGETS SWater
RUNTIME DESTINATION ${THE_ROOT}/bin/
LIBRARY DESTINATION ${THE_ROOT}/bin/ )
## On Windows, copy SDL2.dll and the .pdb
if( WIN32 )
install( FILES ${THE_ROOT}/extern/SDL2/lib/SDL2.dll
DESTINATION ${THE_ROOT}/bin/ )
install( FILES $<TARGET_PDB_FILE:SWater> DESTINATION ${BTX_ROOT}/bin/ OPTIONAL )
endif()