CMake找不到OpenMP [英] CMake cannot find OpenMP

查看:1452
本文介绍了CMake找不到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.cmakeopenmp-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_FLAGSCMAKE_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆