0

I have installed an external library named metis which resides at "/usr/local/opt/" in my system and I want to link this library to my existing make project, which seems to be difficult. I have tried a few reference links here on stackoverflow but they don't seem to work.

My CMakeLists.txt looks like this:

project(Multi)

cmake_minimum_required (VERSION 2.6)

find_package(CGAL QUIET COMPONENTS Core )
  include( ${CGAL_USE_FILE} )

  include_directories (BEFORE "/include")
  include_directories (BEFORE "/dt")

find_package(MPI)
  include_directories(SYSTEM ${MPI_INCLUDE_PATH})
  SET(CMAKE_C_COMPILER mpicc)
  SET(CMAKE_CXX_COMPILER mpicxx)
  SET(MPIEXEC_MAX_NUMPROCS "4" CACHE STRING "Maximum number of processors available to run MPI applications.")

find_package(METIS)
    include_directories("/usr/local/opt/metis/include")
    add_subdirectory("/usr/local/opt/metis/include/bin")

add_executable(example example.cpp)   

I have tried to add the location of the library by using add_subdirectory and include_directories tags but they don't seem to work.

Any help on this will be appreciated.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

0

find_package() searches for the library in a set of predefined directores, and /usr/local/opt is very likely not among those. In this case, since you already know where your library is located, you can tell find_package() where to look for it:

find_package(METIS REQUIRED PATHS /usr/local/opt/metis)

Also, add_subdirectory() works only if the specified directory contains a CMakeLists.txt. You need this only if you want to build the library metis as part of your build process, and if that directory is the root of the metis library, and it used CMake for building too. If you only have the header files and pre-build library files, then you do not need this.

Lyubomir Vasilev
  • 3,000
  • 17
  • 24