-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
77 lines (58 loc) · 2.05 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
cmake_minimum_required (VERSION 3.5)
project(SoftRenderer)
# version
set (SoftRenderer_VERSION_MAJOR 1)
set (SoftRenderer_VERSION_MINOR 0)
# C++ 11 is required
set(CMAKE_CXX_STANDARD 11)
include_directories(include)
include_directories(${PROJECT_SOURCE_DIR}/external/include)
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
link_directories(${PROJECT_SOURCE_DIR}/external/libs)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(SDL2 REQUIRED)
# check if boost was found
if(SDL2_FOUND)
message ("SDL2 found")
else()
message (FATAL_ERROR "Cannot find SDL2")
endif()
ENDIF()
file(GLOB_RECURSE SRCS ./src/*.cpp)
file(GLOB_RECURSE HEADERS include/*.h)
# # Create the executable
# add_executable(${PROJECT_NAME} ${SRCS} ${HEADERS})
add_library(${PROJECT_NAME} ${SRCS} ${HEADERS})
add_library(SoftRenderer::renderer ALIAS ${PROJECT_NAME})
# link the target with the SDL2
target_link_libraries( ${PROJECT_NAME}
SDL2
SDL2main
assimp
)
# 创建并指定可执行程序输出目录
file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# 将模型文件移至可执行文件目录下
# file(COPY obj DESTINATION ${PROJECT_SOURCE_DIR}/bin)
# 将dll文件移至可执行文件目录下
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/Debug)
file(COPY external/dlls/ DESTINATION ${PROJECT_SOURCE_DIR}/bin/Debug)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
file(COPY external/dlls/ DESTINATION ${PROJECT_SOURCE_DIR}/bin)
ENDIF()
# Add sub directories
add_subdirectory(examples/01_PureColor)
add_subdirectory(examples/02_UV)
add_subdirectory(examples/03_Phong)
add_subdirectory(examples/04_Texture)
add_subdirectory(examples/05_BumpedNormal)
add_subdirectory(examples/06_ShadowMap)
add_subdirectory(examples/07_Bloom)
add_subdirectory(examples/08_PointLight)
add_subdirectory(examples/09_SpotLight)
add_subdirectory(examples/10_MultiLight)
add_subdirectory(examples/11_Transparent)
add_subdirectory(examples/12_AmbientOcclusion)
add_subdirectory(examples/13_GeneralScene)