-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (60 loc) · 1.84 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
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(opengl-sine-wave VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
add_compile_options(/utf-8)
endif(MSVC)
# Find QT Library
set(QT_MAJOR_VERSION 5 CACHE STRING "Major version of QT")
find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS
Widgets
)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# Fetch GLM library
include(FetchContent)
FetchContent_Declare(GLM
URL "https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip"
DOWNLOAD_EXTRACT_TIMESTAMP ON
)
FetchContent_MakeAvailable(GLM)
# Executables
file(GLOB_RECURSE SHADER_SOURCE RELATIVE "${CMAKE_SOURCE_DIR}" CONFIGURE_DEPENDS "src/shader/*.vert" "src/shader/*.frag" "src/shader/*.geom")
add_executable(sine-wave
src/ArcBall.h src/ArcBall.cpp
src/DynamicHeightMap.h src/DynamicHeightMap.cpp
src/gl.cpp # Generated by glad
src/main.cpp
src/qtTextureCubeMap.h src/qtTextureCubeMap.cpp
src/qtTextureImage2D.h src/qtTextureImage2D.cpp
src/Shader.h src/Shader.cpp
src/UBO.h src/UBO.cpp
src/WaveWidget.cpp src/WaveWidget.h
src/VAO_Interface.h
src/Wave_VAO.h src/Wave_VAO.cpp
src/Box_VAO.h src/Box_VAO.cpp
src/Plane_VAO.h
${SHADER_SOURCE}
src/images.qrc
)
# Set include directories
target_include_directories(sine-wave PRIVATE include)
# Link libraries
target_link_libraries(sine-wave PRIVATE
Qt${QT_MAJOR_VERSION}::Widgets
glm::glm
)
add_custom_target(copy-shader
COMMAND ${CMAKE_COMMAND} -E copy_directory "src/shader" ${CMAKE_CURRENT_BINARY_DIR}/shader
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_dependencies(sine-wave copy-shader)
add_custom_target(archive
COMMAND git archive --format=zip --prefix=src/ -o src.zip HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Archive the source code"
VERBATIM
)