Skip to content

Commit

Permalink
update CMakeLists files and codes according to reviews
Browse files Browse the repository at this point in the history
Signed-off-by: ZhuohaoHe <[email protected]>
  • Loading branch information
ZzzhHe committed Aug 9, 2024
1 parent 47c179b commit 6f62069
Show file tree
Hide file tree
Showing 32 changed files with 659 additions and 565 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# 设置最小 cmake 版本
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 设置项目名与版本
project(SimpleRenderer
Expand Down Expand Up @@ -42,18 +40,18 @@ set(FONT_FILE_PATH "${wqy_font_SOURCE_DIR}/wqy-zenhei.ttc")
include(ProcessorCount)
ProcessorCount(NPROC)
# 日志文件路径
set(LOG_FILE_PATH "${PROJECT_SOURCE_DIR}/build/logs/SimpleRendererLog.log")
set(LOG_FILE_PATH "${EXECUTABLE_OUTPUT_PATH}/logs/SimpleRendererLog.log")
# 日志文件大小
set(LOG_FILE_MAX_SIZE 1024*1024*4)
# 日志文件数量
set(LOG_FILE_MAX_COUNT 8)
# 生成配置头文件
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/config.h.in"
"${PROJECT_SOURCE_DIR}/include/config.h"
"${PROJECT_SOURCE_DIR}/src/include/config.h"
)

# 添加要编译的目录
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(doc)
add_subdirectory(doc)
147 changes: 80 additions & 67 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,84 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 27,
"patch": 0
},
"configurePresets": [
{
"name": "host",
"description": "Linux Only",
"hidden": true,
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "std",
"description": "This preset makes sure the project actually builds with at least the specified standard",
"hidden": true,
"cacheVariables": {
"CMAKE_C_EXTENSIONS": "OFF",
"CMAKE_C_STANDARD": "23",
"CMAKE_C_STANDARD_REQUIRED": "ON",
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_CXX_STANDARD": "23",
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
}
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
{
"name": "configurePresets_base",
"hidden": true,
"inherits": [
"host",
"std"
],
"displayName": "configurePresets_base",
"description": "base configurePresets",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": {
"type": "BOOL",
"value": "ON"
},
"EXECUTABLE_OUTPUT_PATH": {
"type": "STRING",
"value": "${sourceDir}/build/bin"
},
"LIBRARY_OUTPUT_PATH": {
"type": "STRING",
"value": "${sourceDir}/build/lib"
},
"COVERAGE_OUTPUT_DIR": {
"type": "STRING",
"value": "${sourceDir}/build/coverage"
"configurePresets": [
{
"name": "std",
"description": "This preset makes sure the project actually builds with at least the specified standard",
"hidden": true,
"cacheVariables": {
"CMAKE_C_EXTENSIONS": "OFF",
"CMAKE_C_STANDARD": "23",
"CMAKE_C_STANDARD_REQUIRED": "ON",
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_CXX_STANDARD": "23",
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
}
},
{
"name": "config-base",
"hidden": true,
"inherits": [ "std" ],
"displayName": "config-base",
"description": "base configurePresets",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": {
"type": "BOOL",
"value": "ON"
},
"EXECUTABLE_OUTPUT_PATH": {
"type": "STRING",
"value": "${sourceDir}/build/bin"
},
"LIBRARY_OUTPUT_PATH": {
"type": "STRING",
"value": "${sourceDir}/build/lib"
},
"COVERAGE_OUTPUT_DIR": {
"type": "STRING",
"value": "${sourceDir}/build/coverage"
}
}
},
{
"name": "config-macos",
"hidden": true,
"inherits": [ "config-base" ],
"displayName": "config-base",
"description": "macOS configurePresets",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"CMAKE_MACOSX_RPATH": "1",
"CMAKE_INSTALL_RPATH": "/Library/Frameworks",
"CMAKE_BUILD_WITH_INSTALL_RPATH": "TRUE"
}
},
{
"name": "build",
"hidden": false,
"inherits": [
"config-base"
],
"displayName": "build-base",
"description": "build base configurePresets"
},
{
"name": "build-macos",
"hidden": false,
"inherits": [
"config-macos"
],
"displayName": "build-macos",
"description": "macOS build configurePresets"
}
},
{
"name": "build",
"hidden": false,
"inherits": [
"configurePresets_base"
],
"displayName": "build",
"description": "build"
}
]
}
]
}
17 changes: 2 additions & 15 deletions cmake/3rd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CPMAddPackage(
"gtest_force_shared_crt ON"
)

# SDL2
# https://github.com/libsdl-org/SDL
CPMAddPackage(
NAME SDL2
GITHUB_REPOSITORY libsdl-org/SDL
Expand All @@ -68,8 +68,6 @@ CPMAddPackage(
"SDL_STATIC_PIC ON"
"SDL_WERROR OFF"
)
find_package(SDL2 REQUIRED)


CPMAddPackage(
NAME assimp
Expand All @@ -81,6 +79,7 @@ CPMAddPackage(
"ASSIMP_BUILD_SAMPLES OFF"
)

# https://github.com/g-truc/glm
CPMAddPackage(
NAME glm
GITHUB_REPOSITORY g-truc/glm
Expand Down Expand Up @@ -214,24 +213,12 @@ if (NOT LCOV_EXE)
"Following https://github.com/linux-test-project/lcov to install.")
endif ()

find_package(SDL2 REQUIRED)
if (NOT SDL2_FOUND)
message(FATAL_ERROR "sdl2 not found.\n"
"Following https://github.com/libsdl-org/SDL to install.")
endif ()

find_package(spdlog REQUIRED)
if (NOT spdlog_FOUND)
message(FATAL_ERROR "spdlog not found.\n"
"Following https://github.com/gabime/spdlog to install.")
endif ()

find_package(glm REQUIRED)
if (NOT glm_FOUND)
message(FATAL_ERROR "glm not found.\n"
"Following https://github.com/g-truc/glm tp install")
endif ()

find_package(assimp REQUIRED)
if (NOT assimp_FOUND)
message(FATAL_ERROR "assimp not found.\n"
Expand Down
51 changes: 0 additions & 51 deletions include/face.hpp

This file was deleted.

65 changes: 0 additions & 65 deletions include/log_math.hpp

This file was deleted.

22 changes: 0 additions & 22 deletions include/material.hpp

This file was deleted.

Loading

0 comments on commit 6f62069

Please sign in to comment.