CMake找不到OpenMP [英] CMake cannot find OpenMP
问题描述
我正在尝试使用OpenMP进行编译.我的CMakeLists.txt
包含该行
I am trying to compile with OpenMP. My CMakeLists.txt
contains the line
find_package(OpenMP REQUIRED)
和CMake错误
CMake Error at /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:72 (find_package):
Could not find a configuration file for package openmp.
Set openmp_DIR to the directory containing a CMake configuration file for
openmp. The file will have one of the following names:
openmpConfig.cmake
openmp-config.cmake
检查我的文件系统,发现我有/usr/share/cmake-2.8/Modules/FindOpenMP.cmake
,但没有openmpConfig.cmake
或openmp-config.cmake
.我该怎么做才能解决此问题?
Checking my filesystem, I see that I have /usr/share/cmake-2.8/Modules/FindOpenMP.cmake
but no openmpConfig.cmake
or openmp-config.cmake
. What do I need to do to fix this?
推荐答案
OpenMp
不是软件包,如果受支持,它将作为编译器的一部分提供.尝试相应地设置CMAKE_C_FLAGS
或CMAKE_CXX_FLAGS
.例如:
OpenMp
is not a package, if it's supported, it comes as a part of the your compiler. Try setting CMAKE_C_FLAGS
or CMAKE_CXX_FLAGS
accordingly. e.g:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
激活OpenMP
来编译C
源.对于其他编译器,您应该首先检测该编译器,然后添加适当的标志
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
activates OpenMP
for compiling C
sources when gcc
is used. For other compilers, you should first detect the compiler and then add appropriate flags
这篇关于CMake找不到OpenMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!