[英]How can I skip CMake compiler identification?
I'm running some tests on my software environment.我正在我的软件环境上运行一些测试。 This does hundreds of calls to CMake to configure many projects, always using the same compiler.
这会对 CMake 进行数百次调用以配置许多项目,并且始终使用相同的编译器。
For every call to CMake, it checks the compiler:对于每次调用 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
This takes a while and is useless to be done many time as it will always end with the same result on the machine running those tests.这需要一段时间,并且多次完成是无用的,因为在运行这些测试的机器上它总是以相同的结果结束。
Is there no way to "cache" compiler check result and have it be done once only?有没有办法“缓存”编译器检查结果并且只执行一次?
fdan recommended (in a comment) to add a top level CMake
projects adding all sub-projects using add_subdirectory
. fdan 建议(在评论中)添加顶级
CMake
项目,使用add_subdirectory
添加所有子项目。 I did not try that but it looks like something that would wok.我没有尝试过,但它看起来像是可以炒的东西。
In the mean time, I found an alternative is to:与此同时,我发现另一种选择是:
CMakeLists.txt
fileCMakeLists.txt
文件CMake
on it, it checks the compiler.CMake
,它会检查编译器。 This produces some files including a CMakeCache.txt
and a CMakeFiles
folder.CMakeCache.txt
和CMakeFiles
文件夹。CMake
onCMake
CMakeCache.txt
and a CMakeFiles
folder)CMakeCache.txt
和CMakeFiles
文件夹)CMakeCache.txt
content to reference the new project folder instead of the old one (else Cmake will report CMake Error: The current CMakeCache.txt directory ... is different than the directory ... where CMakeCache.txt was created)
.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.