Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the right place for FindXXX.cmake files for locally compiled libs?

Tags:

I have a lib I installed by hand (to /usr/local) on a Linux system (Eigen3, by the way). There is a FindEigen3.cmake bundled with the lib but that is not installed anywhere by default.

There is /usr/share/cmake-x.y/Modules where CMake looks for additional modules, but putting these files there doesn't seem the way to do things. Is there an equivalent place under /usr/local that is also scanned by default? Or what is the standard way of creating custom library modules?

(Although the question isn't strictly connected to programming, I think library authors may also encounter the same question from the other side: where to put these files when installing manually.)

like image 977
Latanius Avatar asked Apr 03 '11 11:04

Latanius


People also ask

Where are CMake files stored?

Using Modules Allowing CMakeLists files to make use of reusable modules enables the entire community to share reusable sections of code. For CMake, these sections are called cmake-modules and can be found in the Modules subdirectory of your installation.

Where does Find_package look CMake?

CMake ships with its own set of built-in find_package scripts, and their location is in the default CMAKE_MODULE_PATH.

What is CMake module path?

;-list of directories specifying a search path for CMake modules to be loaded by the include() or find_package() commands before checking the default modules that come with CMake. By default it is empty, it is intended to be set by the project.

What is a .CMake file?

A CMAKE file is a project file created by the open-source, cross-platform tool CMake. It contains source script in the CMake language for the entire program. CMake tool uses programming scripts, known as CMakeLists, to generate build files for a specific environment such as makefiles Unix machine.


1 Answers

In our project we place FIndXXX.cmake modules in folder project root dir/cmake/modules. For this to work you have to specify in project root dir/CMakeLists.txt (similiar to what DLRdave has already said):

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)  
like image 58
beduin Avatar answered Jan 06 '23 23:01

beduin