繁体   English   中英

如何跳过 CMake 编译器识别?

[英]How can I skip CMake compiler identification?

我正在我的软件环境上运行一些测试。 这会对 CMake 进行数百次调用以配置许多项目,并且始终使用相同的编译器。

对于每次调用 CMake,它都会检查编译器:

-- Selecting Windows SDK version  to target Windows 10.0.16299.
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done

这需要一段时间,并且多次完成是无用的,因为在运行这些测试的机器上它总是以相同的结果结束。

有没有办法“缓存”编译器检查结果并且只执行一次?

fdan 建议(在评论中)添加顶级CMake项目,使用add_subdirectory添加所有子项目。 我没有尝试过,但它看起来像是可以炒的东西。

与此同时,我发现另一种选择是:

  • 创建一个空的CMakeLists.txt文件
  • 在其上运行CMake ,它会检查编译器。 这会生成一些文件,包括CMakeCache.txtCMakeFiles文件夹。
  • 对于下一个项目,您将在其上运行CMake
    • 复制您对空项目执行的第一次运行的输出(包括CMakeCache.txtCMakeFiles文件夹)
    • 修改CMakeCache.txt内容以引用新项目文件夹而不是旧文件夹(否则 Cmake 将报告CMake Error: The current CMakeCache.txt directory ... is different than the directory ... where CMakeCache.txt was created)
    • 然后在配置下一个项目时将不会进行编译器检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM