hw01 icon indicating copy to clipboard operation
hw01 copied to clipboard

添加 stbiw 库

Open Dizww opened this issue 2 years ago • 0 comments

关于stbi 宏定义设计: 这是一种heard only 的设计方式。用IMPLEMENTATION宏来控制是否导入函数的定义。 没有定义IMPLEMENTATION宏时,导入stbi头文件,只有函数的声明。

我们只在stbiw的stb_image_write.cpp中,导入IMPLEMENTATION宏,以启用stbi函数的定义。

#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>

然后将stbiw编译成一个静态库

add_library(stbiw STATIC stb_image_write.cpp stb_image_write.h)
target_include_directories(stbiw PUBLIC .)

其他项目通过add_subdirectory就可以使用stbiw库了

Dizww avatar Jan 03 '23 15:01 Dizww