【发布时间】:2018-02-27 15:22:55
【问题描述】:
我正在使用一个名为 PyPHS 的 Python 库,专门用于物理建模。 为了在模拟过程中节省计算量,它实现了 C++ 代码生成功能。它使用 CMake 生成特定模拟的可执行文件。
它是在 C++ 11 中实现的。
问题
在 CMakeLists.txt 文件中,C++ 11 功能由以下行激活:
target_compile_features(<project_name> PUBLIC cxx_std_11)
在我的电脑(CMake 3.5.1 & Ubuntu 16.04.4 Xenial Xerus)上,CMake 抛出错误:此功能未知:
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:31 (target_compile_features):
target_compile_features specified unknown feature "cxx_std_11" for target
"dampedosc".
```
-- Configuring incomplete, errors occurred!
See also "/home/victorw/git/vocal-phs/python/output/dampedosc/CMakeFiles/CMakeOutput.log".
在其他安装(Debian 8、Mac OSX 或 windows 7)上没有遇到此错误
修复
我更改了 CMakeLists.txt 模板。这是提交的链接,在我自己的 PyPHS 分支上。
我已将 target_compile_features(<project_name> PUBLIC cxx_std_11) 替换为 set (CMAKE_CXX_STANDARD 11)
问题
这两个命令有什么区别? 您对此事有何见解?我是不是忘了提一些信息?
感谢您的回答!
【问题讨论】: