I am trying to find the required library for my cmake file but i am unable to find it.
This is my cmake code:
find_package(myLib REQUIRED)
This is the error msg which is being shown:
CMake Error at CMakeLists.txt:10 (find_package):
By not providing "FindmyLib.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "myLib", but
CMake did not find one.
Could not find a package configuration file provided by "myLib" with any
of the following names:
myLibConfig.cmake
mylib-config.cmake
Add the installation prefix of "myLib" to CMAKE_PREFIX_PATH or set
"myLib_DIR" to a directory containing one of the above files. If
"myLib" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
Can i know how to fix this.
Maybe you have not added the folder where you placed the custom FindmyLib.cmake to CMAKE_MODULE_PATH.
For example if you have placed FindmyLib.cmake in the folder cmake/modules relative to the CMakeList.txt you are using, add
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
)
in the CMakeList.txt
Related
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.
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.
I used the .cmake files from https://github.com/brendan-w/collector/tree/master/cmake, and I put them in the same directory as my CMakeLists.txt, then I used the code:
set(CMAKE_MODULE_PATH FindSDL2.cmake FindSDL2_image.cmake)
find_package(SDL2 REQUIRED)
but I'm getting the error:
CMake Error at CMakeLists.txt:26 (find_package):
By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SDL2", but
CMake did not find one.
Could not find a package configuration file provided by "SDL2" with any of
the following names:
SDL2Config.cmake
sdl2-config.cmake
Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
"SDL2_DIR" to a directory containing one of the above files. If "SDL2"
provides a separate development package or SDK, be sure it has been
installed.
The CMAKE_MODULE_PATH variable contains a list of paths to your CMake modules (FindSDL2.cmake, FindSDL2_image.cmake, etc. are your modules). You should append the full path to these modules on your machine to this variable:
list(APPEND CMAKE_MODULE_PATH /path/to/your/SDL2/modules)
find_package(SDL2 REQUIRED)
More recently, SDL2 provides a CMake configuration file, that can be used to help CMake find your SDL2 installation. Your error message explicitly describes this, and states the package configuration names (SDL2Config.cmake and sdl2-config.cmake). To allow CMake to find SDL2 using this method instead, use CMAKE_PREFIX_PATH:
list(APPEND CMAKE_PREFIX_PATH /path/to/your/SDL2/config/files)
find_package(SDL2 REQUIRED)
Once CMake finds the package, it will define some SDL2_* variables that can be used in your CMake project:
...
add_executable(MySDL2Executable main.cpp)
include_directories(MySDL2Executable PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(MySDL2Executable PRIVATE ${SDL2_LIBRARIES})
Note, these variable names may differ based on your SDL2 version. Consult the CMake module files or package configuration files themselves for the list of SDL2_* variable names that are defined.
I have found in library Poco under contrib a PocoConfig.cmake which I've copied under /cmake/Modules
I also added in my CMakeLists.txt:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
Now I run under /Build/cmake ..
And I keep getting:
CMake Error at CMakeLists.txt:41 (find_package):
By not providing "FindPoco.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Poco", but
CMake did not find one.
Could not find a package configuration file provided by "Poco" with any of
the following names:
PocoConfig.cmake
poco-config.cmake
Add the installation prefix of "Poco" to CMAKE_PREFIX_PATH or set
"Poco_DIR" to a directory containing one of the above files. If "Poco"
provides a separate development package or SDK, be sure it has been
installed.
Obviously CMake is not finding the module file. What am I doing wrong, how to explicitly point CMake to that module file?
The PocoConfig.cmake doesn't works with find_package (otherwise, it would be named FindPoco.cmake), that's why you're getting this error.
Just include the PocoConfig.cmake in your CMakeLists.txt with:
include(${CMAKE_SOURCE_DIR}/cmake/Modules/PocoConfig.cmake)
I've had similar issues. In my case I was recompiling with an old build folder in place - deleting the folder and recompiling worked.
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()