Sierra上对OpenMP的CMake支持

Sierra上对OpenMP的CMake支持

本文介绍了在macOS High Sierra上对OpenMP的CMake支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将OpenMP添加到使用CMake构建的项目中.我在使用标准CMake/OpenMP附加软件在Linux上构建它时没有问题:

I'm attempting to add OpenMP to a project that is building with CMake. I'm having no problem building it on Linux with the standard CMake/OpenMP addition:

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}")
    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
${OpenMP_EXE_LINKER_FLAGS}")
endif()

不幸的是,这似乎不适用于macOS目标.调用cmake时,会出现以下错误:

Unfortunately this doesn't seem to work on macOS targets. When cmake is called, the following error is given:

-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)

我正在使用macOS High Sierra(10.13.3)和CMake 3.11.我已经通过brew,"brew install libomp"安装了OpenMP 5.01.我以前发现过一些有关这三个问题的文章,但它们似乎都与以前在macOS上安装OpenMP的方式有关,即"brew install clang-omp".

I'm using macOS High Sierra (10.13.3) along with CMake 3.11. I've installed OpenMP 5.01 via brew, 'brew install libomp'. I've found some previous posts commenting on issues regarding these three but they all seem to deal with a previous way of installing OpenMP on macOS, "brew install clang-omp".

我认为这可能与CMake有关,因为我可以使用OpenMP正常使用标准Makefile,因此不支持此OpenMP安装.提供的任何信息将不胜感激.

I'm thinking this might have something to do with CMake not support this OpenMP install as I'm able to use OpenMP no problem with standard makefiles. Any information provided would be much appreciated.

推荐答案

我已经能够回答我自己的问题(很抱歉没有事先弄清楚这一点,希望对其他有相同问题的人有所帮助.)

I've been able to answer my own question (apologies for not figuring this out beforehand, hopefully this can help others with the same issue).

似乎已将补丁提交给CMake,以使其能够使用新的OpenMP安装正确创建构建系统: https://gitlab.kitware.com/cmake/cmake/merge_requests/1812

It seems that a patch has been submitted to CMake to allow it to properly create buildsystems with the new OpenMP install: https://gitlab.kitware.com/cmake/cmake/merge_requests/1812

如果将来有其他人看到此内容,请在阅读时将其更新为CMake 3.12.

For others seeing this in the future, update to CMake 3.12 if it has been released at the time of reading.

这篇关于在macOS High Sierra上对OpenMP的CMake支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 18:45