- 确认已经安装了sdl2_gfx库
在终端输入以下命令:
brew install sdl2_gfx
- 添加以下命令到CMakeLists.txt文件中:
find_package(SDL2_gfx REQUIRED)
target_link_libraries(<your project name> SDL2_gfx::SDL2_gfx)
- 修改CLion配置
在CLion中的设置菜单中:
- 选择Build, Execution, Deployment
- 选择Toolchains
- 点击左下角的 “+” 新建一个Toolchain,并将其选择为默认工具链。
- 点击CMake选项卡
- 将Command line options设置为 -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@1.1
- 将其他的选项按需进行设置
- 重新加载CMake
在CLion中点击菜单栏中的"Tools" -> "CMake" -> "Reload CMake Project",等待加载完成后再次尝试运行应用程序。
这些步骤应该解决M1 Mac使用CLion、CMake和Homebrew遇到sdl2_gfx错误的问题。