| 149 | } |
| 150 | |
| 151 | void cmExportCMakeConfigGenerator::GeneratePolicyHeaderCode(std::ostream& os) |
| 152 | { |
| 153 | // Protect that file against use with older CMake versions. |
| 154 | /* clang-format off */ |
| 155 | os << "# Generated by CMake\n\n" |
| 156 | "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.8)\n" |
| 157 | " message(FATAL_ERROR \"CMake >= " |
| 158 | << this->RequiredCMakeVersionMajor << '.' |
| 159 | << this->RequiredCMakeVersionMinor << '.' |
| 160 | << this->RequiredCMakeVersionPatch << " required\")\n" |
| 161 | "endif()\n" |
| 162 | "if(CMAKE_VERSION VERSION_LESS \"" |
| 163 | << this->RequiredCMakeVersionMajor << '.' |
| 164 | << this->RequiredCMakeVersionMinor << '.' |
| 165 | << this->RequiredCMakeVersionPatch << "\")\n" |
| 166 | " message(FATAL_ERROR \"CMake >= " |
| 167 | << this->RequiredCMakeVersionMajor << '.' |
| 168 | << this->RequiredCMakeVersionMinor << '.' |
| 169 | << this->RequiredCMakeVersionPatch << " required\")\n" |
| 170 | "endif()\n"; |
| 171 | /* clang-format on */ |
| 172 | |
| 173 | // Isolate the file policy level. |
| 174 | // Support CMake versions as far back as the |
| 175 | // RequiredCMakeVersion{Major,Minor,Patch}, but also support using NEW |
| 176 | // policy settings for up to CMake 4.1 (this upper limit may be reviewed |
| 177 | // and increased from time to time). This reduces the opportunity for CMake |
| 178 | // warnings when an older export file is later used with newer CMake |
| 179 | // versions. |
| 180 | /* clang-format off */ |
| 181 | os << "cmake_policy(PUSH)\n" |
| 182 | "cmake_policy(VERSION " |
| 183 | << this->RequiredCMakeVersionMajor << '.' |
| 184 | << this->RequiredCMakeVersionMinor << '.' |
| 185 | << this->RequiredCMakeVersionPatch << "...4.1)\n"; |
| 186 | /* clang-format on */ |
| 187 | } |
| 188 | |
| 189 | void cmExportCMakeConfigGenerator::GeneratePolicyFooterCode(std::ostream& os) |
| 190 | { |