[CMake_Config] hw01 作业: 完成了 stbiw 目录下的 CMake 配置 #118
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
为了回应作业要求,简单看了下与 stb 以及设计原则相关的两个仓库,发现仓库的设计相当有趣。在 cmake 的构建过程中,通过 自己定义 stbw/stbw_config.cpp 文件,将 .h 文件通过宏命令静态切换为实现版本,再生成对应的静态/动态链接库(可以发现 build/stbw/ 目录下的 libstbw.a 文件)。最后,通过 cmake 来链接起项目中源文件,实现了 .h 单文件中接口声明与实现的分离(cpp程序只需要 include 接口版本,链接实现版本生成的链接库)。
我想了想,这样做的好处在于:
坏处可能是:
参考列表