-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganization: GLM Integration, SDL2 on macOS Build Fix, and Structural Enhancements #11
base: main
Are you sure you want to change the base?
Changes from all commits
cebca18
78ba9f3
cebb066
049e985
ecdb542
c877b4d
890c15c
b502e5c
b380f8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,27 +57,29 @@ CPMAddPackage( | |
"gtest_force_shared_crt ON" | ||
) | ||
|
||
# https://github.com/aminosbh/sdl2-cmake-modules.git | ||
# https://github.com/libsdl-org/SDL | ||
CPMAddPackage( | ||
NAME sdl2-cmake-modules | ||
GIT_REPOSITORY https://github.com/aminosbh/sdl2-cmake-modules.git | ||
GIT_TAG ad006a3daae65a612ed87415037e32188b81071e | ||
DOWNLOAD_ONLY True | ||
NAME SDL2 | ||
GITHUB_REPOSITORY libsdl-org/SDL | ||
GIT_TAG release-2.30.6 | ||
OPTIONS | ||
"SDL2_DISABLE_INSTALL ON" | ||
"SDL_SHARED OFF" | ||
"SDL_STATIC ON" | ||
"SDL_STATIC_PIC ON" | ||
"SDL_WERROR OFF" | ||
) | ||
if (sdl2-cmake-modules_ADDED) | ||
list(APPEND CMAKE_MODULE_PATH ${sdl2-cmake-modules_SOURCE_DIR}) | ||
endif () | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 目前的习惯是 CPMAddPackage 放在一起,find_package 放在一起,最好统一格式,改成旧有的分开或者改成按模块 |
||
## https://github.com/freetype/freetype | ||
#CPMAddPackage( | ||
# NAME freetype | ||
# GIT_REPOSITORY https://github.com/freetype/freetype.git | ||
# GIT_TAG VER-2-13-0 | ||
# VERSION 2.13.0 | ||
#) | ||
#if (freetype_ADDED) | ||
# add_library(Freetype::Freetype ALIAS freetype) | ||
#endif () | ||
# # https://github.com/aminosbh/sdl2-cmake-modules.git | ||
# CPMAddPackage( | ||
# NAME sdl2-cmake-modules | ||
# GIT_REPOSITORY https://github.com/aminosbh/sdl2-cmake-modules.git | ||
# GIT_TAG ad006a3daae65a612ed87415037e32188b81071e | ||
# DOWNLOAD_ONLY True | ||
# ) | ||
# if (sdl2-cmake-modules_ADDED) | ||
# list(APPEND CMAKE_MODULE_PATH ${sdl2-cmake-modules_SOURCE_DIR}) | ||
# endif () | ||
|
||
# https://github.com/tinyobjloader/tinyobjloader.git | ||
CPMAddPackage( | ||
|
@@ -95,6 +97,13 @@ if (tinyobjloader_ADDED) | |
) | ||
endif () | ||
|
||
# https://github.com/g-truc/glm | ||
CPMAddPackage( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 加一个 github 链接 |
||
NAME glm | ||
GITHUB_REPOSITORY g-truc/glm | ||
GIT_TAG 1.0.1 | ||
) | ||
|
||
# https://github.com/nothings/stb.git | ||
CPMAddPackage( | ||
NAME stb | ||
|
@@ -111,19 +120,6 @@ if (stb_ADDED) | |
) | ||
endif () | ||
|
||
# https://gitlab.com/libeigen/eigen.git | ||
CPMAddPackage( | ||
NAME Eigen | ||
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git | ||
GIT_TAG 3.4.0 | ||
VERSION 3.4.0 | ||
DOWNLOAD_ONLY True | ||
) | ||
if (Eigen_ADDED) | ||
add_library(Eigen INTERFACE IMPORTED) | ||
target_include_directories(Eigen INTERFACE ${Eigen_SOURCE_DIR}) | ||
endif () | ||
|
||
# http://wenq.org/wqy2/index.cgi?ZenHei | ||
CPMAddPackage( | ||
NAME wqy_font | ||
|
@@ -235,12 +231,6 @@ 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(OpenMP REQUIRED) | ||
if (NOT OpenMP_FOUND) | ||
message(FATAL_ERROR "OpenMP not found.\n" | ||
|
@@ -251,4 +241,4 @@ find_package(spdlog REQUIRED) | |
if (NOT spdlog_FOUND) | ||
message(FATAL_ERROR "spdlog not found.\n" | ||
"Following https://github.com/gabime/spdlog to install.") | ||
endif () | ||
endif () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里 glm 的 CPMAddPackage 和 find_package 又分开写了,注意统一哈 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,31 +5,21 @@ | |
# CMakeLists.txt for Simple-XX/SimpleRenderer. | ||
|
||
# 生成静态库 | ||
add_library(${PROJECT_NAME} STATIC | ||
log_system.cpp | ||
color.cpp | ||
include/vector.hpp | ||
include/matrix.hpp | ||
include/model.hpp | ||
include/shader_base.h | ||
include/default_shader.h | ||
include/light.h | ||
model.cpp | ||
light.cpp | ||
shader_base.cpp | ||
default_shader.cpp | ||
simple_renderer.cpp | ||
file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS | ||
"*.cpp" | ||
"*.c" | ||
) | ||
add_library(${PROJECT_NAME} STATIC ${SRC_FILES}) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/include> | ||
$<INSTALL_INTERFACE:include> | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
${DEFAULT_COMPILE_OPTIONS} | ||
${DEFAULT_COMPILE_OPTIONS} | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE | ||
${DEFAULT_LINK_LIB} | ||
${DEFAULT_LINK_LIB} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cmakelist 的对齐你是用的什么?我是 clion 默认的对齐方案,这样比较省事,如果你有好用的工具可以推荐下 |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ class Model { | |
/// 法向量 | ||
using Normal = Vector3f; | ||
/// 贴图 | ||
using TextureCoord = Vector2f; | ||
using TextureCoord = glm::vec2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我们不是有 Vector2f 嘛,直接用呗 |
||
|
||
class Material { | ||
public: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个在 CMakePresets.json 里面设置过了,可以删掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
但是删掉之后,就会在std::span的地方报错
参考这个链接
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我发现了,是因为CMakePresets.json这个文件我没设置好,导致在跑命令
cmake --list-presets
的时候没有输出列表,然后就没办法用这个preset,我简单调整了一下preset的代码,现在可以正常使用preset跑了。&
这两个地方都可以按照原本的代码直接跑,我下个commit会删掉我的更改