Several handy CMake modules for common routines often done across the projects.
add_clean_target_subdirectory
Adds a subdirectory with several certain building control variables cleared. At the moment it clears upBUILD_EXAMPLES
,BUILD_TESTS
andBUILD_DOCUMENTATION
. Otherwise it's equal toadd_subdirectory()
CMake command. OptionalALL
parameter can be used to disableEXCLUDE_FROM_ALL
option 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, addsuninstall
target to the CMake project as per officially suggested code snippet.
generate_pc_file
Generatespkg-config
's*.pc
file for the project. Automatically applies installation directories usingGNUInstallDirs
CMake module and scans library dependencies of main project target (usesPROJECT_TARGET_NAME
andPROJECT_NAME
variables for the target name).
-
git_version
Tries to guess project version out of current tag title printed bygit describe
. -
git_commit_version
Tries to guess project version analysing the output ofgit describe
, with latest commit hash included together with tag title (like1.0.1-a1b2c3d4
).
-
new_test
Adds 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_test
Adds test, that checks, that the compilation fails for certain test case file (in other words, if compilation fails, test passes, otherwise it fails).
prefixsuffix
Adds prefix and suffix specified in the parameter list to each item of the list, replacing the original content of the list.prefix
Adds prefix specified in the parameter list to each item of the list, replacing the original content of the list.suffix
Adds suffix specified in the parameter list to each item of the list, replacing the original content of the list.
three_part_version_to_vars
parses compiled version with dotted notation (usually stored inPROJECT_VERSION
variable) to major, minor and patch parts separately.