How can I use cmake to locate jupyter notebook installation - cmake

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

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.

Related

cmake find_package unable to find Eigen3Config.cmake spectra Windows

I am using Eigen3 with spectra (https://spectralib.org/), a library built on top of Eigen. Spectra uses find_package to find Eigen, and comes up with the error:
Could not find a package configuration file provided by "Eigen3" with any
of the following names:
Eigen3Config.cmake
eigen3-config.cmake
Looking through the directory of Eigen, I found that there were no files by those names, but rather one called Eigen3Config.cmake.in. I tried copying the file and renaming it Eigen3Config.cmake, but that gave me a different error of
find_package Error reading CMake code from "C:/Program Files
(x86)/Eigen3/cmake/Eigen3Config.cmake".
which was somewhat expected, but it does tell me that it can at least find the directory where Eigen3Config.cmake.in is. I'm assuming that either find_package is supposed to use Eigen3Config.cmake.in, or Eigen3Config.cmake.in is supposed to generate Eigen3Config.cmake, but i'm very new to cmake, so i'm not sure. How do I fix this?
There is no need to build/install Eigen to use it if you include it manually, as done in the getting started example (https://eigen.tuxfamily.org/dox/GettingStarted.html#title0)
But in order to be found by CMake, you will need to build / install it, as explained in the INSTALL file. https://gitlab.com/libeigen/eigen/-/blob/master/INSTALL
Usually, your error is followed by an hint asking you to set the variable Eigen3_DIR (or something similar) to point the build/install dir of the target project (Eigen3 here). It appears typically when you have built but not installed the project.
So:
Build Eigen
Install it (optional)
For spectra set the cmake var Eigen3_DIR to /path/to/Eigen/build . (if eigen not install or still not found)
These steps worked for me:
Install Eigen
Create a build directory for Eigen
cd into the build directory created
run "cmake ../"Your Eigen Source Directory""
After this is done, in your CMakeLists.txt of your project, you'll want to add "find_package( Eigen3 REQUIRED)" and "include_directories( ${EIGEN3_INCLUDE_DIR})".

kdev-ruby's CMakeFile.txt requires weird stuff like KF5Config.cmake

I'm trying to compile a Ruby plugin for KDevelop: https://github.com/KDE/kdev-ruby
When I cut a folder called build, cd build, and run cmake .., I get lots of errors:
CMake Error at CMakeLists.txt:13 (include):
include could not find load file:
KDEInstallDirs
CMake Error at CMakeLists.txt:14 (include):
include could not find load file:
KDECMakeSettings
CMake Error at CMakeLists.txt:15 (include):
include could not find load file:
KDECompilerSettings
CMake Error at CMakeLists.txt:16 (include):
include could not find load file:
ECMQtDeclareLoggingCategory
CMake Error at CMakeLists.txt:24 (find_package):
By not providing "FindKF5.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "KF5", but
CMake did not find one.
Could not find a package configuration file provided by "KF5" (requested
version 5.15.0) with any of the following names:
KF5Config.cmake
kf5-config.cmake
Add the installation prefix of "KF5" to CMAKE_PREFIX_PATH or set "KF5_DIR"
to a directory containing one of the above files. If "KF5" provides a
separate development package or SDK, be sure it has been installed.
How, on Ubuntu, do I install something that provides KF5Config.cmake? Preferably without rebuilding KDevelop or KDE or Qt5.
KDevelop relies on the development headers for various libraries, and finds them via the accompanying CMake files.
The build also uses CMake modules provided by the extra-cmake-modules package.
You must install that and libkf5config-dev.
The apt-file command might help you find the relevant packages for your distro in these situations.

Building a VS2015 x64 project using glew 1.13.0 and CMake 3.4.0

How do I build a VS2015 x64 project using glew 1.13.0 and CMake 3.4.0?
I prepared a minimal demo that can be found here: https://bitbucket.org/Vertexwahn/cmakedemos/src/2fbbc02b2c0567319d7be070b34391b1ef35048d/GlewDemo/?at=default
CMakeLists.txt:
cmake_minimum_required ( VERSION 2.8)
project ( GlewDemo )
find_package(GLEW REQUIRED)
set ( SRCS main.cpp )
add_executable(GlewDemo ${SRCS})
target_link_libraries(GlewDemo glew32s)
I downloaded the prebuilt binaries from here: http://sourceforge.net/projects/glew/files/glew/1.13.0/glew-1.13.0-win32.zip/download
And set the path of GLEW_INCLUDE_DIR to the corresponding directory ("C:\Users\no68koc\Downloads\glew-1.13.0\include")
But CMake gives me some errors:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find GLEW (missing: GLEW_LIBRARY)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindGLEW.cmake:44 (find_package_handle_standard_args)
CMakeLists.txt:4 (find_package)
Configuring incomplete, errors occurred!
See also "C:/build/vs2015/GlewDemo/CMakeFiles/CMakeOutput.log".
How does it work properly?
Error message
Could NOT find GLEW (missing: GLEW_LIBRARY)
is a standard message generated by FindXXX.cmake script (called via find_package(XXX)), that it is failed to set(deduce) some CMake variables, so whole package is assumed to be not found.
Most of FindXXX.cmake scripts descibes(in the comment), which variables are set by the script for user.
But only several of them describes, how user can help script in case when the script failed to find needed package at all, or if user wants script to find specific package installation instead of default one.
There is no universal approach in helping to the FindXXX.cmake script, in most cases one should analize code of the script for know variables, which can help.
In the given case (with GLEW package) analizing CMake-provided FindGLEW.cmake script reveals, that both find_path() call (which set GLEW_INCLUDE_DIR variable) and find_library() call (which set GLEW_LIBRARY variable) use no hints (HINT or PATH options) for search. But there are standard hints, which are used by both of this commands. One of these hints is ${CMAKE_PREFIX_PATH}/include directory for find_path and similar directory for find_library.
So you can use
list(APPEND CMAKE_PREFIX_PATH "C:\Users\no68koc\Downloads\glew-1.13.0")
for hint to find_library() and find_path() to search under this directory too.
Alternatively, you may set CMAKE_PREFIX_PATH variable in CMake cache either in GUI (e.g. inside Visual Studio) or via command line:
cmake -DCMAKE_PREFIX_PATH:PATH=C:\Users\no68koc\Downloads\glew-1.13.0
(Note, that using list(APPEND ...) instead of set(...) within CMakeLists.txt does not override variable in case it is set in cache too).
You may use another, 3d-party FindGLEW.cmake script
You can download it into your project (e.g., to cmake/FindGLEW.cmake) and issue
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
for tell find_package() to use this script instead of default one.
Given script uses
${GLEW_LOCATION}
directory (and its subdirectories) as hint for searching in find_path() and find_library() (under PATH command's option). So you can set GLEW_LOCATION variable to installation directory:
set(GLEW_LOCATION "C:\Users\no68koc\Downloads\glew-1.13.0")
for make things work. Alternatively(and preferrably), this variable can be set in cache.
Also, given FindGLEW.cmake script uses
$ENV{GLEW_LOCATION}
directory as hint. This means that setting GLEW_LOCATION environment variable will also helps.
CMake cannot locate your GLEW. Thus you have to hint CMake.
Either include GLEW to some place, where CMake looks for components. Installing GLEW comes to mind.
Or you define the variables manually. You already did that for GLEW_INCLUDE_DIR. You have to define GLEW_LIBRARY, too.
It must be the path to the library named glew32, glew, or glew32s. With Unices it should be lib*.so maybe with some additional version numbers. With Windows it should be *.dll or *.lib.

Where should I install FindXXX.cmake file of my own project and how to find it?

I am developing two CMake projects: libABC and libXYZ. libXYZ requires libABC, and so I would like install FindABC.cmake in an appropriate location on Mac and Linux machines.
libABC and its related files are installed under /usr/local by default, and I think FindABC.cmake also should be installed under the same directory. I tried installing it in the following six different locations.
/usr/local/lib/cmake/ABC/FindABC.cmake
/usr/local/share/cmake/ABC/FindABC.cmake
/usr/local/lib/ABC/FindABC.cmake
/usr/local/share/ABC/FindABC.cmake
/usr/local/lib/ABC/cmake/FindABC.cmake
/usr/local/share/ABC/cmake/FindABC.cmake
However CMakeList.txt of libXYZ cannot find it with the following error.
CMake Error at CMakeLists.txt:51 (find_package):
By not providing "FindABC.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"ABC", but CMake did not find one.
My cmake command was installed under /opt/local by using MacPorts on OS X. So I think it searches not /usr/local but only /opt/local.
I know that defining CMAKE_MODULE_PATH when executing cmake command solve this issue (e.g., cmake -DCMAKE_MODULE_PATH=/usr/local/lib/cmake/ABC), but I do not want to ask all users to do it every time.
My questions are
Q1. Where should I install FindABC.cmake during the libABC installation process?
Q2. How do I properly find FindABC.cmake in CMakeLists.txt of libXYZ without hard-coding CMAKE_MODULE_PATH in it?

Error with Ogre and CMake

I installed Ogre3D 1.8.1 (the source package) on Ubuntu 12.04 and everything went fine (I managed to run some samples on the Ogre interface). However, I hit a problem while I was compiling an external project (that one) that needed the OpenCV, ArUco and Ogre librarys. When I run the CMake of the project, I receive the following:
CMake Error at CMakeLists.txt:46 (find_package):
By not providing "FindOGRE.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OGRE", but
CMake did not find one.
Could not find a package configuration file provided by "OGRE" with any of
the following names:
OGREConfig.cmake
ogre-config.cmake
Add the installation prefix of "OGRE" to CMAKE_PREFIX_PATH or set
"OGRE_DIR" to a directory containing one of the above files. If "OGRE"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
I know where the FindOGRE.cmake is, it's in the /usr/local/lib/OGRE/cmake, but I don't know how to say to CMake to look for that folder and fix this problem.
You just need to use the -D command line option along with the CMAKE_MODULE_PATH variable:
cmake . -DCMAKE_MODULE_PATH=/usr/local/lib/OGRE/cmake
Just for the record, an alternative solution would be to add the module path directly in the CMakeLists.txt. For example (tested on Debian 9):
set(CMAKE_MODULE_PATH "/usr/share/OGRE/cmake/modules/;${CMAKE_MODULE_PATH}")
Just make sure to add the line before find_package is called.
For me, it only works to set the following in CMakeLists.txt before find_package:
set(OGRE_DIR /usr/share/OGRE/build/sdk/CMake)
Note that the CMake directory is the one containing OGREConfig.cmake. For some reason, my CMake ignores CMAKE_MODULE_PATH.
Maybe, of some help for someone
For me, this solution work on manjaro:
set(CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake;${CMAKE_MODULE_PATH}")
find_package(OGRE QUIET)
if (OGRE_FOUND)
include_directories( ${ogre_INCLUDE_DIR})
link_directories(${OGRE_LIBRARIES})
message(STATUS "OGRE: FOUND")
else()
message(STATUS "OGRE: NOT FOUND")
endif()