![]() ![]() This method of saving the state between between runs of the CMake command comes from the CMake-git-version-tracking repository. We can write the git commit hash using the file(WRITE) command and then we can file(STRINGS) command to read the content of the file back into CMake. Since we don’t have access to the CMake cache when running in CMake’s script mode, we have to save this information into an external file called git-state.txt. We only want to regenerate the git_version.cpp if the git hash has actually changed. Once the repository is cloned, you can list all the tags using the following. Type the following command to clone the repository and tags: 3. Open the terminal or command prompt in the directory where you want to clone the repository. The only thing left is that we want to reduce the amount of work done. To clone tags in Git, you can use the tags flag with the git clone command. We almost have all of the pieces together. This allows the byproducts to be used in other parts of the CMake script otherwise there would be an error indicating that the file is missing, but in reality the file has just not been generated yet, which isn’t a problem. We also have to specify the BYPRODUCTS of the command. These must be passed along since a CMake script file does not have access to the cache so we must pass these values along. The -Dpre_configure_file and -Dpost_configure_file include the directories that the configuration files are from and the generated data should go. ![]() the -DRUN_CHECK_GIT_VERSION=1 tells the script that we should run the CheckGitVersion function. We must also pass any variables we want the script to have access through the -D arguments. The -P indicates that we should run cmake in a script mode which means that it will run the cmake file, not modify the cache at all. # Get the latest abbreviated commit hash of the working branchĬOMMAND git log -1 -format=%h WORKING_DIRECTORY $ indicates that we should run the cmake executable for this command. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |