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.
find_package()searches for the library in a set of predefined directores, and/usr/local/optis very likely not among those. In this case, since you already know where your library is located, you can tellfind_package()where to look for it:Also,
add_subdirectory()works only if the specified directory contains aCMakeLists.txt. You need this only if you want to build the librarymetisas part of your build process, and if that directory is the root of themetislibrary, 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.