1

I am trying to compile my project and my project is using sqlcipher package. sqlcipher is cloned and installed in a custom path and I exported this path through $PATH in the ~/.bashrc file. After configuration if I type sqlcipher in the terminal its working fine, but when I try to cmake my project on the same terminal its giving

-- Checking for one of the modules 'sqlcipher'
CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:578 (message):
  None of the required 'sqlcipher' found

I guess I have to provide this custom path to cmake for finding this package. How to provide custom path to cmake? Where I am doing the mistake?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Gilson PJ
  • 3,443
  • 3
  • 32
  • 53
  • You need to set `CMAKE_PREFIX_PATH` variable, like described here: https://stackoverflow.com/questions/34795816/hinting-findname-cmake-files-with-a-custom-directory/34797156#34797156. – Tsyvarev Oct 05 '18 at 06:46
  • @Tsyvarev I tried `cmake -DCMAKE_INSTALL_PREFIX=/tmp/xyz/ -DCMAKE_PREFIX_PATH=/home/iam/git/LIB_ROOT/bin ..` but not working – Gilson PJ Oct 05 '18 at 06:52
  • @Tsyvarev After removing `bin` from the above path its working. thank you so much. – Gilson PJ Oct 05 '18 at 06:58
  • Variable `CMAKE_PREFIX_PATH` should contain **installation prefix**, not a `bin/` directory with a program. Also make sure that you have `.pc` file installed (under given installation prefix) - exactly this file is searched by `pkg-config` utility. – Tsyvarev Oct 05 '18 at 06:58

1 Answers1

3

The module FindPkgConfig.cmake defines functions pkg_check_modules() and pkg_search_module, which use pkg-config utility for locate the package.

The utility itself takes hints for searching from PKG_CONFIG_PATH environment variable, which contains colon-separated (:) paths with .pc files:

export PKG_CONFIG_PATH="/home/iam/git/LIB_ROOT/lib/pkgconfig:${PKG_CONFIG_PATH}"
cmake <...>

But the CMake functions also take hints from CMAKE_PREFIX_PATH variable, which contains semicolon-separated (;) install prefixes of the packages. Both flows of variable are accepted, environment and CMake ones:

export CMAKE_PREFIX_PATH="/home/iam/git/LIB_ROOT;${CMAKE_PREFIX_PATH}"
cmake <...>

or

cmake -DCMAKE_PREFIX_PATH:PATH=/home/iam/git/LIB_ROOT <...>

Approach with setting CMAKE_PREFIX_PATH is a common way for hint CMake for search packages: https://stackoverflow.com/a/34797156/3440745.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • Note: `CMAKE_PREFIX_PATH` works for pkg-config only if `cmake_minimum_required` is 3.1+ OR if you set `PKG_CONFIG_USE_CMAKE_PREFIX_PATH` to true. – Xeverous Dec 04 '19 at 19:23