这里加入了DOWNLOAD_EXTRACT_TIMESTAMP TRUE选项,缺失会涉及到如何处理解压后文件时间戳的问题,CMake会给一个警告比较烦。 如果我们希望和 find_package 兼容:能在本地找到就执行 find_package,否则执行 FetchContent_Declare,可以使用下面的语法 include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https...
{TO_CMAKE_PATH | TO_NATIVE_PATH} <path> <out-var>) Transfer file(DOWNLOAD <url> [<file>] [...]) file(UPLOAD <file> <url> [...]) Locking file(LOCK <path> [...]) Archiving file(ARCHIVE_CREATE OUTPUT <archive> PATHS <paths>... [...]) file(ARCHIVE_EXTRACT INPUT <archive>...
so the `DOWNLOAD_EXTRACT_TIMESTAMP` property of `ExternalProject_Add()` command is set by default on CMake v3.24 and up. it helps to set the a more accurate timestamp for the downloaded content, hence the targets depending on the extracted content can be rebuilt if the URL changes. see...
(CONFIGURE <string> <out-var> [...]) # 类似 configure_file 命令 # string(MAKE_C_IDENTIFIER <string> <out-var>) # 非字母数字字符转换为下划线 # string(RANDOM [<option>...] <out-var>) # 生成随机字符串 # string(TIMESTAMP <out-var> [<format string>] [UTC]) # 时间字符串 # ...
DOWNLOAD_EXTRACT_TIMESTAMPONEXCLUDE_FROM_ALL) For earlier versions of CMake, you can replaceFetchContent_MakeAvailable(Boost)with this: FetchContent_GetProperties(Boost)if(NOTBoost_POPULATED)message(STATUS"Fetching Boost") FetchContent_Populate(Boost)message(STATUS"Configuring Boost")add_subdirectory(${Boos...
1.4 TIMESTAMP file(TIMESTAMP <filename> <variable> [<format>] [UTC]) 描述: 获取文件的时间戳,并将其存储在中。如果命令无法获取时间戳变量将被设置为空字符串("")。 参数: <filename>:指定要获取时间戳的文件路径。 <variable>:指定存储时间戳的变量名。
file(DOWNLOAD <url> [<file>] [...]) file(UPLOAD <file> <url> [...]) Locking file(LOCK <path> [...]) Archiving file(ARCHIVE_CREATE OUTPUT <archive> PATHS <paths>... [...]) file(ARCHIVE_EXTRACT INPUT <archive> [...]) ...
file(TIMESTAMP <filename> <out-var> [...]) file(GET_RUNTIME_DEPENDENCIES [...]) Writing file({WRITE | APPEND} <filename> <content>...) file({TOUCH | TOUCH_NOCREATE} [<file>...]) file(GENERATE OUTPUT <output-file> [...]) ...
# 只生成 Release 的配置 (多配置的情况下)cmake ../ -DCMAKE_CONFIGURATION_TYPES=Release# 生成cmake --build ./# 因为只生成了 Release 的配置,所以报错说没有 Debug|x64 的配置# C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(437,5...
Copying pre- serves input file timestamps, and optimizes out a file if it exists at the destination with the same time- stamp. Copying preserves input permissions unless explicit permissions or NO_SOURCE_PERMISSIONS are given (default is USE_SOURCE_PERMISSIONS). See the install(DIRECTORY) ...