报错提示:Add the installation prefix of “xxx“ to CMAKE_PREFIX_PATH or set“xxx_DIR“ to a directory
解决方案:
1.检查有无编译安装对应的库,检查库名称下有无对应的build文件夹,没有的话先下载并编译:
sudo git clone https://github.com/g-truc/glm.git
sudo chmod -R 777 /home/xxx/glm (glm库下载后无权限需赋予权限)
cd build
cmake ..
make
sudo make install
注:本文遇到的缺失库glm为OpenGL Mathematics (GLM),是基于OpenGL着色语言(GLSL)规范的图形软件的头文件C ++数学库。编译完成后不用链接静态库、动态库,直接包含hpp文件后可以直接编写代码。
2.若已经安装编译完成的库,按照报错提示在cmakelist 文件中添加路径
set(glm_DIR "/home/xxx/glm/build") //自己的路径
find_package(glm REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})
3.安装并添加库文件路径后C++项目CMake配置成功,如下所示。
-- Build type: Release
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxx/Projects/system_v9/cmake-build-debug
[Finished]