Skip to content

Commit 6f62069

Browse files
committed
update CMakeLists files and codes according to reviews
Signed-off-by: ZhuohaoHe <zhuohao.he@outlook.com>
1 parent 47c179b commit 6f62069

32 files changed

Lines changed: 659 additions & 565 deletions

CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
# 设置最小 cmake 版本
88
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)
99

10-
set(CMAKE_CXX_STANDARD 20)
11-
set(CMAKE_CXX_STANDARD_REQUIRED True)
1210

1311
# 设置项目名与版本
1412
project(SimpleRenderer
@@ -42,18 +40,18 @@ set(FONT_FILE_PATH "${wqy_font_SOURCE_DIR}/wqy-zenhei.ttc")
4240
include(ProcessorCount)
4341
ProcessorCount(NPROC)
4442
# 日志文件路径
45-
set(LOG_FILE_PATH "${PROJECT_SOURCE_DIR}/build/logs/SimpleRendererLog.log")
43+
set(LOG_FILE_PATH "${EXECUTABLE_OUTPUT_PATH}/logs/SimpleRendererLog.log")
4644
# 日志文件大小
4745
set(LOG_FILE_MAX_SIZE 1024*1024*4)
4846
# 日志文件数量
4947
set(LOG_FILE_MAX_COUNT 8)
5048
# 生成配置头文件
5149
configure_file(
5250
"${PROJECT_SOURCE_DIR}/cmake/config.h.in"
53-
"${PROJECT_SOURCE_DIR}/include/config.h"
51+
"${PROJECT_SOURCE_DIR}/src/include/config.h"
5452
)
5553

5654
# 添加要编译的目录
5755
add_subdirectory(src)
5856
add_subdirectory(test)
59-
add_subdirectory(doc)
57+
add_subdirectory(doc)

CMakePresets.json

Lines changed: 80 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,84 @@
11
{
2-
"version": 6,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 27,
6-
"patch": 0
7-
},
8-
"configurePresets": [
9-
{
10-
"name": "host",
11-
"description": "Linux Only",
12-
"hidden": true,
13-
"condition": {
14-
"type": "equals",
15-
"lhs": "${hostSystemName}",
16-
"rhs": "Linux"
17-
}
18-
},
19-
{
20-
"name": "std",
21-
"description": "This preset makes sure the project actually builds with at least the specified standard",
22-
"hidden": true,
23-
"cacheVariables": {
24-
"CMAKE_C_EXTENSIONS": "OFF",
25-
"CMAKE_C_STANDARD": "23",
26-
"CMAKE_C_STANDARD_REQUIRED": "ON",
27-
"CMAKE_CXX_EXTENSIONS": "OFF",
28-
"CMAKE_CXX_STANDARD": "23",
29-
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
30-
}
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 23,
6+
"patch": 0
317
},
32-
{
33-
"name": "configurePresets_base",
34-
"hidden": true,
35-
"inherits": [
36-
"host",
37-
"std"
38-
],
39-
"displayName": "configurePresets_base",
40-
"description": "base configurePresets",
41-
"binaryDir": "${sourceDir}/build",
42-
"cacheVariables": {
43-
"CMAKE_EXPORT_COMPILE_COMMANDS": {
44-
"type": "BOOL",
45-
"value": "ON"
46-
},
47-
"EXECUTABLE_OUTPUT_PATH": {
48-
"type": "STRING",
49-
"value": "${sourceDir}/build/bin"
50-
},
51-
"LIBRARY_OUTPUT_PATH": {
52-
"type": "STRING",
53-
"value": "${sourceDir}/build/lib"
54-
},
55-
"COVERAGE_OUTPUT_DIR": {
56-
"type": "STRING",
57-
"value": "${sourceDir}/build/coverage"
8+
"configurePresets": [
9+
{
10+
"name": "std",
11+
"description": "This preset makes sure the project actually builds with at least the specified standard",
12+
"hidden": true,
13+
"cacheVariables": {
14+
"CMAKE_C_EXTENSIONS": "OFF",
15+
"CMAKE_C_STANDARD": "23",
16+
"CMAKE_C_STANDARD_REQUIRED": "ON",
17+
"CMAKE_CXX_EXTENSIONS": "OFF",
18+
"CMAKE_CXX_STANDARD": "23",
19+
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
5820
}
21+
},
22+
{
23+
"name": "config-base",
24+
"hidden": true,
25+
"inherits": [ "std" ],
26+
"displayName": "config-base",
27+
"description": "base configurePresets",
28+
"binaryDir": "${sourceDir}/build",
29+
"cacheVariables": {
30+
"CMAKE_EXPORT_COMPILE_COMMANDS": {
31+
"type": "BOOL",
32+
"value": "ON"
33+
},
34+
"EXECUTABLE_OUTPUT_PATH": {
35+
"type": "STRING",
36+
"value": "${sourceDir}/build/bin"
37+
},
38+
"LIBRARY_OUTPUT_PATH": {
39+
"type": "STRING",
40+
"value": "${sourceDir}/build/lib"
41+
},
42+
"COVERAGE_OUTPUT_DIR": {
43+
"type": "STRING",
44+
"value": "${sourceDir}/build/coverage"
45+
}
46+
}
47+
},
48+
{
49+
"name": "config-macos",
50+
"hidden": true,
51+
"inherits": [ "config-base" ],
52+
"displayName": "config-base",
53+
"description": "macOS configurePresets",
54+
"condition": {
55+
"type": "equals",
56+
"lhs": "${hostSystemName}",
57+
"rhs": "Darwin"
58+
},
59+
"cacheVariables": {
60+
"CMAKE_MACOSX_RPATH": "1",
61+
"CMAKE_INSTALL_RPATH": "/Library/Frameworks",
62+
"CMAKE_BUILD_WITH_INSTALL_RPATH": "TRUE"
63+
}
64+
},
65+
{
66+
"name": "build",
67+
"hidden": false,
68+
"inherits": [
69+
"config-base"
70+
],
71+
"displayName": "build-base",
72+
"description": "build base configurePresets"
73+
},
74+
{
75+
"name": "build-macos",
76+
"hidden": false,
77+
"inherits": [
78+
"config-macos"
79+
],
80+
"displayName": "build-macos",
81+
"description": "macOS build configurePresets"
5982
}
60-
},
61-
{
62-
"name": "build",
63-
"hidden": false,
64-
"inherits": [
65-
"configurePresets_base"
66-
],
67-
"displayName": "build",
68-
"description": "build"
69-
}
70-
]
71-
}
83+
]
84+
}

cmake/3rd.cmake

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ CPMAddPackage(
5656
"gtest_force_shared_crt ON"
5757
)
5858

59-
# SDL2
59+
# https://github.com/libsdl-org/SDL
6060
CPMAddPackage(
6161
NAME SDL2
6262
GITHUB_REPOSITORY libsdl-org/SDL
@@ -68,8 +68,6 @@ CPMAddPackage(
6868
"SDL_STATIC_PIC ON"
6969
"SDL_WERROR OFF"
7070
)
71-
find_package(SDL2 REQUIRED)
72-
7371

7472
CPMAddPackage(
7573
NAME assimp
@@ -81,6 +79,7 @@ CPMAddPackage(
8179
"ASSIMP_BUILD_SAMPLES OFF"
8280
)
8381

82+
# https://github.com/g-truc/glm
8483
CPMAddPackage(
8584
NAME glm
8685
GITHUB_REPOSITORY g-truc/glm
@@ -214,24 +213,12 @@ if (NOT LCOV_EXE)
214213
"Following https://github.com/linux-test-project/lcov to install.")
215214
endif ()
216215

217-
find_package(SDL2 REQUIRED)
218-
if (NOT SDL2_FOUND)
219-
message(FATAL_ERROR "sdl2 not found.\n"
220-
"Following https://github.com/libsdl-org/SDL to install.")
221-
endif ()
222-
223216
find_package(spdlog REQUIRED)
224217
if (NOT spdlog_FOUND)
225218
message(FATAL_ERROR "spdlog not found.\n"
226219
"Following https://github.com/gabime/spdlog to install.")
227220
endif ()
228221

229-
find_package(glm REQUIRED)
230-
if (NOT glm_FOUND)
231-
message(FATAL_ERROR "glm not found.\n"
232-
"Following https://github.com/g-truc/glm tp install")
233-
endif ()
234-
235222
find_package(assimp REQUIRED)
236223
if (NOT assimp_FOUND)
237224
message(FATAL_ERROR "assimp not found.\n"

include/face.hpp

Lines changed: 0 additions & 51 deletions
This file was deleted.

include/log_math.hpp

Lines changed: 0 additions & 65 deletions
This file was deleted.

include/material.hpp

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)