为什么这个 CMake 脚本找到"alloca"但仍然失败?
Why does this CMake script find "alloca" and still fail?
我正在我的一个项目中使用 alloca
函数,并决定使用 CMake 来确保它可用。所以我把这个位添加到我的CMakeLists.txt文件中:
include(CheckSymbolExists)
check_symbol_exists(alloca stdlib.h;cstdlib ALLOCA_EXISTS)
if (NOT ALLOCA_EXISTS)
message(FATAL_ERROR "Platform does not support alloca")
endif ()
当我运行 CMake 时,这是(相关部分(输出:
-- Looking for alloca
-- Looking for alloca - found
CMake Error at CMakeLists.txt:11 (message):
Platform does not support alloca
-- Configuring incomplete, errors occurred!
那么为什么显示的代码找到了函数但没有设置变量呢?还是别的什么?
指定标头时必须添加引号:
check_symbol_exists(alloca "stdlib.h;cstdlib" ALLOCA_EXISTS)
否则,将忽略ALLOCA_EXISTS
,并使用值 TRUE
创建变量cstdlib
。
相关文章:
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 视图中的参数推导失败:take_while
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 从父数组测试用例构造二叉树失败
- LibGit2 SSH身份验证失败
- 如何让LLDB在成功时退出,在失败时等待
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 生成MRPT库时cmake配置失败
- 为什么除非添加括号,否则构造函数上的模板替换会失败?
- 为什么这个 CMake 脚本找到"alloca"但仍然失败?