Jordan He
Jordan He

Reputation: 350

How to tell CMake where to find the directory of a library?

I am trying to install glnemo2 on a desktop which I don't have root access. The OS is CentOS. glnemo2 requires CCfits which I installed locally at $HOME/local/CCfits. So, I downloaded and untarred the source file, and following the instruction all I need to do is

  cd build
  cmake ..
  make
  make install

However, during make it complains: fatal error: CCfits: No such file or directory #include <CCfits>.

So, my question is, how to tell cmake where to look for the installed CCfits library?

Upvotes: 2

Views: 986

Answers (1)

Mizux
Mizux

Reputation: 9291

Looking at the glnemo2 project:

  1. There is no find_package(CCfits) src: https://gitlab.lam.fr/jclamber/glnemo2/blob/master/CMakeLists.txt

  2. They use a CMAKE_MODULE_PATH
    https://gitlab.lam.fr/jclamber/glnemo2/blob/master/CMakeLists.txt#L20-21

  3. but they do not provide any FindCCfits.cmake module

  4. They use an ugly (not target_include_directories() + hard coded path):

include_directories(/usr/include/CCfits /opt/local/include /opt/local/include/CCfits  /usr/include/cfitsio /usr/local/include/CCfits)

src: https://gitlab.lam.fr/jclamber/glnemo2/blob/master/CMakeLists.txt#L156
then an other hackish

target_link_libraries (glnemo2 ... CCfits cfitsio ...)

src: https://gitlab.lam.fr/jclamber/glnemo2/blob/master/CMakeLists.txt#L230

The quick solution would be to modify these lines,
less hack would be to provide a findCCfits.cmake with a let's say target CCfits::CCfits.

Upvotes: 1

Related Questions