node.jscmakeswigpocketsphinx

CMake Error: Could NOT find SWIG (missing: SWIG_DIR)


I wanted to test out Pocketsphinx in Node.JS. It says I need to install Swig version 3.0.7 or above.

I think I installed all the other dependencies correctly. I can even type Swig commands in the Terminal now, but I keep getting this error whenever I run npm install pocketsphinx:

CMake Error at /usr/local/Cellar/cmake/3.6.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find SWIG (missing: SWIG_DIR) (Required is at least version
  "3.0.7")
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.6.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.6.3/share/cmake/Modules/FindSWIG.cmake:75 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:4 (find_package)

I tried brew install swig, npm install swig, and npm install -g swig. I tried going to the swig download page and following the installation instructions, but nothing I seem to do stops the error from happening. I'm trying this on a Macbook by the way.

I really have no clue what I'm doing here. I just wanted to test out Pocketsphinx and now I've installed Swig in 4 different places, and CMake can't seem to recognise any of them.

Any help would be wonderful!


Solution

  • Came here looking for the Windows-based error. I found a solution that seems to work for me, so decided to post it here.