Given your comment on arrowdodgerโs answer about fear, installing something would ruin your system, which I decided to give a conceptual comment in the form of an answer because of its length.
The cmake chain project works through find_package, which searches for * Config.cmake and * -config.cmake files.
Project A CMakeLists.txt:
Project B CMakeLists.txt:
project(B) find_package(A)
Then
$ mkdir build $ cd build $ cmake -DCMAKE_INSTALL_PREFIX=/tmp/test-install .. $ make install
leads to
...
B was found by A because he set AConfig.cmake to the location where cmake finds his "share / A / cmake" And they gave him the same value for CMAKE_INSTALL_PREFIX.
Now here's the thing. Let's think about what you can do in AConfig.cmake: AFAIK is all you want. But the most common task is to pull out information about A objects via include (), do some additional find_package invoctions for third-party package packages (TIP), and create variables
A_LIBRARIES A_INCLUDE_DIRS
What you want to include is the file created
install(EXPORT A-targets DESTINATION share/A/cmake )
in A CMakeLists.txt, where the A-target refers to the global cmake variable that accumulates all the information about the target when used in
install(TARGETS ... EXPORT A-targets ... )
statments. What was created with make install
/tmp/test-install/share/A/cmake/A-targets.cmake
which is next to AConfig.cmake in the same directory. Please take another look at the wiki page on how to use this file inside AConfig.cmake.
Regarding the export () command: This is convenient if your projects have become HUGE and require a significant amount to install them. To speed up the process, you want to use what is in A build / directory. This optimization is also explained on the wiki. It still works through find_package (), see
But I strongly recommend that you go on the usual make install route for now.