Several handy CMake modules for common routines often done across the projects.
add_clean_target_subdirectoryAdds a subdirectory with several certain building control variables cleared. At the moment it clears upBUILD_EXAMPLES,BUILD_TESTSandBUILD_DOCUMENTATION. Otherwise it's equal toadd_subdirectory()CMake command. OptionalALLparameter can be used to disableEXCLUDE_FROM_ALLoption toadd_subdirectory, which seems to be expected default behaviour when including CMake subproject with the command.
add_uninstall_target(run implicitly on including the module) As uninstallation is not supported in CMake by default for conceptual reasons, addsuninstalltarget to the CMake project as per officially suggested code snippet.
generate_pc_fileGeneratespkg-config's*.pcfile for the project. Automatically applies installation directories usingGNUInstallDirsCMake module and scans library dependencies of main project target (usesPROJECT_TARGET_NAMEandPROJECT_NAMEvariables for the target name).
-
git_versionTries to guess project version out of current tag title printed bygit describe. -
git_commit_versionTries to guess project version analysing the output ofgit describe, with latest commit hash included together with tag title (like1.0.1-a1b2c3d4).
-
new_testAdds new test cases for CTest the easy way, i.e. executable, linking and test at once. Optional second and next parameters may include the library dependencies. -
new_compilation_fail_testAdds test, that checks, that the compilation fails for certain test case file (in other words, if compilation fails, test passes, otherwise it fails).
prefixsuffixAdds prefix and suffix specified in the parameter list to each item of the list, replacing the original content of the list.prefixAdds prefix specified in the parameter list to each item of the list, replacing the original content of the list.suffixAdds suffix specified in the parameter list to each item of the list, replacing the original content of the list.
three_part_version_to_varsparses compiled version with dotted notation (usually stored inPROJECT_VERSIONvariable) to major, minor and patch parts separately.