Cmake Download_dir __link__ May 2026

: Do not try to move files manually after CMake has downloaded them. CMake uses timestamps in the STAMP_DIR to track progress; moving files will break the dependency tracking.

: This cache variable controls where all content population directories (source, build, and sub-build) are collected. The default is ${CMAKE_BINARY_DIR}/_deps . cmake download_dir

In this example, the ExternalProject module will save the lib.tar.gz file into a downloads folder inside your build directory before extracting it into the source directory. DOWNLOAD_DIR vs. FETCHCONTENT_BASE_DIR : Do not try to move files manually

While FetchContent_Declare supports DOWNLOAD_DIR (inherited from ExternalProject), developers more frequently use FETCHCONTENT_BASE_DIR to control the root of all dependency operations. The default is ${CMAKE_BINARY_DIR}/_deps

: When overriding DOWNLOAD_DIR , always use absolute paths (e.g., using ${CMAKE_BINARY_DIR} ) to ensure the location is consistent across different generator environments.

The ExternalProject module is the classic way to manage external builds. When adding an external project that downloads a tarball or zip file from a URL, you can explicitly set the download location: