osx和clion,找不到omp.h

时间:2015-12-10 13:33:01

标签: macos cmake openmp clion

如何说服cmake(在CLion内)我有OpenMP标头可用?我正在尝试编译此项目SCD,我收到以下错误

...
[ 15%] Building CXX object tools/selector/CMakeFiles/selector.dir/source/main.cpp.o
[ 18%] Building CXX object tools/cc/CMakeFiles/cc.dir/source/main.cpp.o
/Users/buddha/github/buddha314/SCD/tools/wcc/source/main.cpp:22:10: fatal error: 'omp.h' file not found
#include <omp.h>
     ^

CMakeLists.txt包含

SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -pg -fopenmp -DPROFILE ") 
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp -DNDEBUG")    

1 个答案:

答案 0 :(得分:0)

我认为您的问题并非特定于CLion,而是用于构建过程的工具(即CMake)。正如this answer中已经提到的,有一个标准模块用于测试编译器是否支持OpenMP:

find_package(OpenMP)
if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()