CMAKE所需的标头系统/Stat.h找不到

CMAKE Required header sys/stat.h not found

本文关键字:Stat 找不到 系统 CMAKE      更新时间:2023-10-16

我正在尝试配置使用cmake的bcl2fastq程序。我找到了触发此错误消息的行

file:bcl2fastq/src/cmake/cxxConfigure.cmake
############## content ####################
..... # ignoring many lines
bcl2fastq_find_header_or_die(HAVE_SYS_STAT_H  sys/stat.h)
......# more lines following

错误消息:

-- time.h found as /usr/include/time.h
-- unistd.h found as /usr/include/unistd.h
CMake Error at cmake/macros.cmake:80 (message):
  Required header sys/stat.h not found.
Call Stack (most recent call first):
  cmake/cxxConfigure.cmake:41 (bcl2fastq_find_header_or_die)
  cxx/CMakeLists.txt:34 (include)

在我的系统上,sys/stat.h位于

/usr/include/x86_64-linux-gnu

过去,我将/usr/include中的符号链接添加到sys/stat.h,该链接修补了问题。有人可以通过修改CMAKE文件提出更好的方法吗?

更深入地挖掘,我在与cxxConfigure.cmake的目录中找到了macros.cmake文件,其中包含宏定义:

#   
# Macro to find libraries, with support for static-only search
#
macro(bcl2fastq_find_header_or_die variable file)
find_file(${variable} ${file} HINTS ENV C_INCLUDE_PATH ENV CPATH ENV CPLUS_INCLUDE_PATH)
if    (${variable})
    message(STATUS "${file} found as ${${variable}}")
else  (${variable})
    message(FATAL_ERROR "Required header ${file} not found.")
endif (${variable})
endmacro(bcl2fastq_find_header_or_die)

然后我做了以下操作:

export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu

之后,Cmake似乎很高兴。不确定这是解决此问题的正确方法。

导出环境变量如

export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu

是一种用途。

此外,根据find_path命令的DOC,PATHS应在HINTS上用于硬编码猜测,这意味着像This

进行修改macros.cmake
find_file([...] PATHS /usr/include/x86_64-linux-gnu)

更合适。为了提高灵活性,它也可以与PATHS ENV变量结合使用。在此处的CMAKE邮件列表中也询问了PATHS vs HINTS的使用,但是该解释的提供并不比文档条目提供更多。

我创建了一个名为sys in/usr/include的文件夹。

通过stat.h复制到该文件夹中,然后再次运行make命令。BCL2FASTQ构建完成没有任何问题。

在代码中写<sys/stat.h>而不是<stat.h>