CMake 无法检测 gcc 内置函数,如 sqrt、pow、exp 等
CMake can't detect gcc built-in functions such as sqrt, pow ,exp and so on
我只是想使用cmake检测是否存在GCC的某些内置功能。因此,我使用check_function_exists
命令进行一些检查工作。这是CMakeLists.txt
中的我的代码片段。
include (CheckFunctionExists)
set (CMAKE_REQUIRED_INCLUDES math.h)
set (CMAKE_REQUIRED_LIBRARIES m)
check_function_exists(sqrt HAVE_SQRT)
check_function_exists (pow HAVE_POW)
check_function_exists (exp HAVE_EXP)
check_function_exists (log HAVE_LOG)
TutorialConfig.h.in
中的代码段
// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
#cmakedefine USE_MYMATH
#cmakedefine HAVE_SQRT
#cmakedefine HAVE_POW
#cmakedefine HAVE_LOG
#cmakedefine HAVE_EXP
  但是,当我在源目录下执行Cmake
命令时,目录。我有这样的错误,很奇怪。
-- The C compiler identification is GNU 7.0.0
-- The CXX compiler identification is GNU 7.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- 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
-- Looking for sqrt
CMake Error: The source directory "../build/CMakeFiles/CMakeTmp" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
CMake Error at /usr/share/cmake/Modules/CheckFunctionExists.cmake:70 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
CMakeLists.txt:23 (check_function_exists)
  但是,错误消息中声称的目录确实存在。
$ ls -la ../build/CMakeFiles/CMakeTmp
total 0
drwxrwxrwx 1 root root 0 Apr 14 21:41 .
drwxrwxrwx 1 root root 0 Apr 14 20:32 ..
  我不是CMake
的专家,所以我不知道什么是关键。
  这是我的日志文件,由cmake
输出希望任何熟悉CMAKE的人都可以帮助我。预先感谢。
错误消息
CMake Error: The source directory "../build/CMakeFiles/CMakeTmp" does not exist.
如果A 相对路径用作构建目录。
虽然在文档中未明确说明它(并且未经CMAKE本身检查(,但最好将绝对路径用作build Directory 。
。因为构建目录 cmake Project的不是设计为移动到其他位置(甚至在其他机器上(,因此没有理由使用相对路径为此。
相关文章:
- 在C++中如何在没有pow的情况下进行基础计算
- 求出有多少个数字是完美平方,而sqrt()是L,R范围内的素数
- 理解GCC中的std::pow实现
- 子例程,不使用 pow,并带有参数和返回
- 整数溢出,最大值为 pow(10,19)
- 如果我重新定义 sqrt 函数,为什么使用 std::sqrt 失败?
- 使用未声明的标识符"sqrt"?
- 在 SVM-Struct 中未定义对 sqrt 的引用(已使用 -lm)
- 在 while 循环中使用 pow() 函数 C++
- 在C++不使用 POW 的情况下处理负指数
- 重载标准::sqrt
- C++ 中 pow() 函数的输出没有给出准确的答案
- CMake 无法检测 gcc 内置函数,如 sqrt、pow、exp 等
- 为什么编译器允许我调用 pow 和 sqrt,即使我没有包含 cmath?
- sqrt(x)和pow(x,0.5)之间的差异
- 使用sqrt()和pow()函数会产生不同的结果
- 为什么sqrt()在智能感知中使用两个pow()的内部计算是错误的
- 用于OpenCV pow和sqrt的Intel TBB
- 是否有任何C++编译器能够优化 lround(pow(sqrt(i), 2)) 现在或不久的将来用 i 替换它
- Sqrt () pow() fab()不起作用