YCM-USING(7)
β¨ YCM-USING β¨
okay bestie, so this is ycm-using β the YCM manual, page 7 β and it's literally the whole "how do I actually use YCM in my project" tutorial. pull up a chair, we're doing this together π«Ά
π HOW TO USE YCM IN YOUR PROJECT π
So first things first: if you wanna use YCM in your project, your software has to depend on CMake 3.12 or later. no older, no exceptions, that's the vibe check. so your CMakeLists.txt file needs to include a cmake_minimum_required() call, which sets the CMAKE_MINIMUM_REQUIRED_VERSION and the relative CMake policies β¨
cmake_minimum_required(VERSION 3.12)
now, next step: you gotta set the variables that control which components get enabled. and listen β all of the following variables should be set before you call find_package(YCM). like, before before. it is not possible to change their value later. periodt π
By default, YCM makes available some modules from CMake that received bugfix, enhancement, or simply are not available in all the supported versions. if you want, you can disable this behaviour by setting the YCM_USE_CMAKE_<VERSION> and YCM_USE_CMAKE_NEXT variables to OFF π
# set(YCM_USE_CMAKE_3_13 OFF) # Disable modules from CMake 3.13
# set(YCM_USE_CMAKE_3_14 OFF) # Disable modules from CMake 3.14
# set(YCM_USE_CMAKE_3_15 OFF) # Disable modules from CMake 3.15
# set(YCM_USE_CMAKE_NEXT OFF) # Disable modules from CMake git repository
These options are turned on by default, but they can be turned off if they are not needed π
SEE ALSO: YCM_USE_CMAKE_<VERSION>, YCM_USE_CMAKE_NEXT.
YCM contains also some CMake modules with unmerged patches. these ones are turned off by default, but you can enable them with the YCM_USE_CMAKE_PROPOSED variable πΈ
set(YCM_USE_CMAKE_PROPOSED ON) # Enables unmerged patches to CMake modules
These options is turned on by default, but it can be turned off if needed. At the moment, it is recommended to turn it on for YCM superbuilds π§
SEE ALSO: YCM_USE_CMAKE_PROPOSED.
All the YCM_USE_CMAKE_ options can be disabled simultaneously by setting the YCM_USE_CMAKE variable to OFF β¨
SEE ALSO: YCM_USE_CMAKE.
YCM makes available a few 3rd party modules. these modules can have licenses that are not the same as the YCM license. so if you're using these modules, you should check each license to make sure it's compatible with your code, fr fr π If you want to disable all 3rd party modules you can set the YCM_USE_3RDPARTY variable to OFF
# set(YCM_USE_3RDPARTY OFF) # Disable 3rd party modules
Also this option is turned on by default, but it can be turned off if it is not needed.
SEE ALSO: YCM_USE_3RDPARTY
Finally, YCM makes available a few modules that are considered deprecated. that's the YCM_USE_DEPRECATED variable. Please note that these modules are deprecated for a reason, therefore they are not supported, might contain bugs, and could be removed in future releases π They are still available to support old code, but it is strongly recommended to avoid them in new code. If you want to disable the deprecated modules, you can set the YCM_USE_DEPRECATED to OFF
# set(YCM_USE_DEPRECATED OFF) # Disable deprecated modules
SEE ALSO: YCM_USE_DEPRECATED
YCM can be both a hard dependency or a soft dependency in your project. in the first case, your package will not build if the YCM package is not installed. in the second case, if it is not installed, it will be downloaded and built during the configure phase of your project π
π Using YCM as a Hard Dependency π
To make it a hard dependency, you can just use it like any other package:
# Find YCM
find_package(YCM [version] REQUIRED)
This is the recommended mode to use it when you just want to use YCM modules, because in this way you will not need a network connection when building the package π₯
π¦ Using YCM as Soft Dependency π¦
To make it a soft dependency, you will need to get the files tools/YCMBootstrap.cmake and modules/IncludeUrl.cmake from the YCM sources (see ycm-installing(7) for instructions on how to download YCM) and copy them inside your project tree:
cd <YOUR_PROJECT_DIR>
mkdir cmake
cp <PATH_TO_YCM_SOURCES>/tools/YCMBootstrap.cmake cmake
cp modules/IncludeUrl.cmake cmake
These files must be in a folder included in CMAKE_MODULE_PATH for your project:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Now you can include YCMBootstrap.cmake:
# Uncomment the next line to specify a tag or a version.
# set(YCM_TAG [tag, branch, or commit hash])
# Bootstrap YCM
include(YCMBootstrap)
This is the suggested method when you build a superbuild. Downloading all your project would require a network connection anyway, therefore you will need to install.
In both cases, you can use YCM modules right after this declaration β¨
π COPYRIGHT π
Copyright 2012-2021 Istituto Italiano di Tecnologia (IIT)
and that's the whole page bestie, we ate and left no crumbs π this was YCM version 0.13. from Nov 05, 2023 β go build something iconic with it πβ¨
π¦ where this page comes from
- ubuntu noble: ycm-cmake-modules 0.13.0-3 Β· BSD-3-Clause
- ubuntu questing: ycm-cmake-modules 0.13.0-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms