I’m trying to get a cross-plattform build system working using CMake. Now the software has a few dependencies. I compiled them myself and installed them on my system.
Some example files which got installed:
-- Installing: /usr/local/share/SomeLib/SomeDir/somefile
-- Installing: /usr/local/share/SomeLib/SomeDir/someotherfile
-- Installing: /usr/local/lib/SomeLib/somesharedlibrary
-- Installing: /usr/local/lib/SomeLib/cmake/FindSomeLib.cmake
-- Installing: /usr/local/lib/SomeLib/cmake/HelperFile.cmake
Now CMake has a find_package()
which opens a Find*.cmake
file and searches after the library on the system and defines some variables like SomeLib_FOUND
etc.
My CMakeLists.txt contains something like this:
set(CMAKE_MODULE_PATH "/usr/local/lib/SomeLib/cmake/;${CMAKE_MODULE_PATH}")
find_package(SomeLib REQUIRED)
The first command defines where CMake searches after the Find*.cmake
and I added the directory of SomeLib
where the FindSomeLib.cmake
can be found, so find_package()
works
as expected.
But this is kind of weird because one of the reasons why find_package()
exists is to get away from non-cross-plattform hard coded paths.
How is this usually done? Should I copy the cmake/
directory of SomeLib
into my project and set the CMAKE_MODULE_PATH
relatively?