0

Is there a way to use cmake find_package() to locate jupyter_notebook installation?

I tried

FIND_PACKAGE(jupyter-notebook REQUIRED)

but it errors out with

CMake Error at CMakeLists.txt:15 (FIND_PACKAGE):
  By not providing "Findjupyter-notebook.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "jupyter-notebook", but CMake did not find one.

  Could not find a package configuration file provided by "jupyter-notebook"
  with any of the following names:

    jupyter-notebookConfig.cmake
    jupyter-notebook-config.cmake

  Add the installation prefix of "jupyter-notebook" to CMAKE_PREFIX_PATH or
  set "jupyter-notebook_DIR" to a directory containing one of the above
  files.  If "jupyter-notebook" provides a separate development package or
  SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!

However, it has been installed:

apt-cache show jupyter-notebook
Rock
  • 994
  • 1
  • 7
  • 12
  • `find_package` is usually used to find libraries. I'm not familiar with jupyter, but is it a library? If it's an application (my quick googling suggests this), then you actually want `find_program`. – Stephen Newell Apr 25 '19 at 03:03
  • @Stephen Newell Thanks, I added your suggestion to my answer. – Kevin Apr 25 '19 at 12:46

1 Answers1

1

There are a few options when using the find_package command, MODULE and CONFIG. For this case, you likely want the CONFIG setting. The error message is trying to help here. Did either of these files come with the jupyter-notebook installation?

jupyter-notebookConfig.cmake
jupyter-notebook-config.cmake

If so, try setting CMAKE_PREFIX_PATH or jupyter-notebook_DIR to the directory where jupyter-notebook was installed. So you might try something like the following:

list(APPEND CMAKE_PREFIX_PATH /path/to/your/installation) # Try this one.
# SET(jupyter-notebook_DIR /path/to/your/installation) # Or try this one.
FIND_PACKAGE(jupyter-notebook CONFIG REQUIRED)

If your installation does not appear to have the aforementioned CMake config files, nor does it appear to have any CMake support files (a cmake directory, etc.), the find_program command is likely more appropriate for jupyter-notebook.

I suggest spending some time with the documentation for find_package, as it explicitly lays out the search paths (in order) CMake uses to find your packages. Also, check out this answer.

Kevin
  • 16,549
  • 8
  • 60
  • 74