1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
14 /** \class cmFilePathChecksum
15 * @brief Generates a checksum for the parent directory of a file
17 * The checksum is calculated from the relative file path to the
18 * closest known project directory. This guarantees reproducibility
19 * when source and build directory differ e.g. for different project
22 class cmFilePathChecksum
25 /// Maximum number of characters to use from the path checksum
26 static const size_t partLengthDefault
= 10;
28 /// @brief Parent directories are empty
31 /// @brief Initializes the parent directories manually
32 cmFilePathChecksum(std::string
const& currentSrcDir
,
33 std::string
const& currentBinDir
,
34 std::string
const& projectSrcDir
,
35 std::string
const& projectBinDir
);
37 /// @brief Initializes the parent directories from a makefile
38 cmFilePathChecksum(cmMakefile
* makefile
);
40 /// @brief Allows parent directories setup after construction
42 void setupParentDirs(std::string
const& currentSrcDir
,
43 std::string
const& currentBinDir
,
44 std::string
const& projectSrcDir
,
45 std::string
const& projectBinDir
);
47 /* @brief Calculates the path checksum for the parent directory of a file
50 std::string
get(std::string
const& filePath
) const;
52 /* @brief Same as get() but returns only the first length characters
55 std::string
getPart(std::string
const& filePath
,
56 size_t length
= partLengthDefault
) const;
59 /// List of (directory name, seed name) pairs
60 std::array
<std::pair
<std::string
, std::string
>, 4> parentDirs
;