YCM-BUILD-SYSTEM-SUPPORT(7)
๐ NAME ๐
ycm-build-system-support โ YCM Build System Support. bestie it's the whole vibe of what YCM hands you for your build system ๐
โจ YCM BUILD SYSTEM SUPPORT โจ
okay so YCM literally offers a lil bundle of macros and Find scripts you can drop straight into your build system. it's giving supportive friend energy. here's what's in the bag ๐ซถ
- Generic Modules โ these add whole new functionalities to CMake that might be useful in your project โจ
- Find Package Modules โ these are the ones that help you find software on the system ๐
- Packaging Helper Modules โ these simplify the generation of a package that can be used by other packages ๐
- Support for new CMake features in older CMake versions โ yes, backporting, we love to see it
- Support for new features in CMake before these are actually released โ living in the future fr fr ๐ฎ
- Support for 3rd party CMake modules โ the more the merrier
SEE ALSO:
if you wanna know about using YCM in your project, go read ycm-using(7) ๐
YCM also offers functionalities to make a superbuild. the docs for that live somewhere else (iykyk).
SEE ALSO:
YCM Superbuild
๐ธ A PRACTICAL EXAMPLE ๐ธ
so like, imagine you made a package with a library in it, and it's called TemplatePkg. you want to package that library โ with versioning, installation rules for your header files AND your binary files, plus cmake files so other projects can find and use the library. iconic behaviour, honestly ๐
here's the code you need to add to your CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(TemplatePkg
LANGUAGES CXX
VERSION 0.0.1)
include(GNUInstallDirs)
# Set the output dir for binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
# find and use YCM
find_package(YCM REQUIRED)
# Set a few
set(${PROJECT_NAME}_BUILD_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(${PROJECT_NAME}_BUILD_BINDIR ${CMAKE_INSTALL_BINDIR})
set(${PROJECT_NAME}_BUILD_INCLUDEDIR ${CMAKE_SOURCE_DIR}/src)
set(${PROJECT_NAME}_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(${PROJECT_NAME}_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
set(${PROJECT_NAME}_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
# add sources
add_subdirectory(src)
so far? nothing special, no cap. we declared our library, added source codes, and included YCM. that's it.
now we need to instruct CMake to install the library and generate CMake (FindTemplatePkg.cmake) have also been generated so that TemplatePkg can be found using CMake ๐ฅ
# include macro for installing packaging files and invoke it
include(InstallBasicPackageFiles)
install_basic_package_files(TemplatePkg
VARS_PREFIX ${PROJECT_NAME}
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY SameMajorVersion
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
this function generates ALL the configuration files that other packages need in order to locate and use the library compiled by TemplatePkg, and it adds the required installation rules for those files. obsessed ๐
finally we add uninstall rules:
include(AddUninstallTarget)
and now you can compile the package by simply doing:
mkdir build
cd build
cmake ..
make
make install
this will install your package using /usr/local/ as the installation prefix. you can change that prefix by changing the CMAKE_INSTALL_PREFIX variable, like for example
cmake -DCMAKE_INSTALL_PREFIX:PATH=/opt/ycm ..
if you peek inside the build directory or <prefix>/lib you should see that make install has built the project and installed the header files and the library correctly. the file TemplatePkgConfig.cmake should be sitting in <prefix>/lib/cmake/TemplatePkg/. that file is what other packages will find when they call:
find_package(TemplatePkg)
example code can be downloaded from the TemplatePkg repository ๐ฆ
๐ COPYRIGHT ๐
Copyright 2012-2021 Istituto Italiano di Tecnologia (IIT)
okay bestie that's the whole page ๐ฆ this was YCM version 0.13., dated Nov 05, 2023, and the page itself is YCM-BUILD-SYSTEM-SUPPORT(7). go forth and build, you absolute main character ๐๐
โจ
๐ฆ 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