I am working on various projects, some of which offer a .cmake extension which I want to install whenever the development package of the project is installed on your Ubuntu system.
The modules of cmake 2.8 are saved under
/usr/share/cmake-2.8/Modules/...
and I thought that was were I would want to install my own extensions (knowing that it would break once we go to cmake-3.0).
However, there seems to be another location where packages install their own extensions:
/usr/share/cmake/<project-name>/...
Is there a place where I could find documentation about this? So far my searches on Google have not pointed me in the right direction...
I have found the following answer, but that seems to be specific to cmake and not Ubuntu:
CMake: Where to install FooBarConfig.cmake and FooBarConfigVersion.cmake?
You can use the CMake package configuration mechanism, which you mentioned in your question.
Imaging you have the following CMake files:
SomeProjectConfig.cmake
SomeProjectConfigVersion.cmake
SomeProjectExtensions.cmake
The SomeProjectConfig.cmake
and SomeProjectConfigVersion.cmake
can be generated by CMakePackageConfigHelpers module.
You can install them into /usr/share/cmake/SomeProject/
folder, for example. For full list of default paths used by CMake see find_package documentation.
In your SomeProjectConfig.cmake
you can include the SomeProjectExtensions.cmake
file or expand CMAKE_MODULE_PATH
variable to let user include the CMake script:
# SomeProjectConfig.cmake
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
set(SOME_PROJECT_SOME_VAR "...")
function(some_project_func)
...
endfunction()
Now your users might use your CMake scripts via find_package
:
# User CMakeLists.txt
find_package(SomeProject REQUIRED)
message(STATUS "SOME_PROJECT_SOME_VAR = ${SOME_PROJECT_SOME_VAR}")
some_project_func()
include(SomeProjectExtensions)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With