I am receiving the following CMake Error:
Errors << project_ros:cmake
/home/nando/project_ws/logs/project_ros/build.cmake.020.log CMake
Error at /home/nando/project_ws/src/project_ros/CMakeLists.txt:22
(find_package): By not providing "Findlibusb-1.0.cmake" in
CMAKE_MODULE_PATH this project has asked CMake to find a package
configuration file provided by "libusb-1.0", but CMake did not find
one.
Could not find a package configuration file provided by "libusb-1.0"
with any of the following names:
libusb-1.0Config.cmake
libusb-1.0-config.cmake
Add the installation prefix of "libusb-1.0" to CMAKE_PREFIX_PATH or
set "libusb-1.0_DIR" to a directory containing one of the above
files. If "libusb-1.0" provides a separate development package or
SDK, be sure it has been installed.
However, I think I am providing "Findlibusb-1.0.cmake" in CMAKE_MODULE_PATH correctly.
This is in my CMakeLists.txt:
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/project_ros/cmakeModules/")
And in src/project_ros/cmakeModules I have Findlibusb-1.0.cmake.
In this thread the same error was appearing but the reason was a typo I don't have.
Any other idea?
Related
I went over the grpc installation and finished building and installation.
Now when I try to:
find_package(gRPC CONFIG REQUIRED)
I get
CMake Error at CMakeLists.txt:15 (find_package):
Found package configuration file:
/usr/lib64/cmake/grpc/gRPCConfig.cmake
but it set gRPC_FOUND to FALSE so package "gRPC" is considered to be NOT
FOUND. Reason given by package:
The following imported targets are referenced, but are missing:
protobuf::libprotobuf protobuf::libprotoc
Event though
find_package(Protobuf REQUIRED)
Works just fine.
I read I'm supposed to run cmake ../.. -DBUILD_DEPS=ON -DBUILD_SHARED_LIBS=ON to solve this. However that results in:
CMake Error at cmake/abseil-cpp.cmake:38 (find_package):
Could not find a package configuration file provided by "absl" with any of
the following names:
abslConfig.cmake
absl-config.cmake
Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
"absl_DIR" to a directory containing one of the above files. If "absl"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:191 (include)
-- Configuring incomplete, errors occurred!
See also "/home/ray/CLionProjects/grpc/grpc/CMakeFiles/CMakeOutput.log".
See also "/home/ray/CLionProjects/grpc/grpc/CMakeFiles/CMakeError.log".
Content of /usr/lib64/cmake/grpc/gRPCConfig.cmake
# Module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules)
# Depend packages
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
The problem is actually with the project you use via find_package() and with its package file (/usr/lib64/cmake/grpc/gRPCConfig.cmake in your case). The error message
The following imported targets are referenced, but are missing:
means, that the package file references IMPORTED targets but they are never defined.
The usual reason for that problem is following:
During its own build, the project uses find_package() for some other packages. This find_package() call defines IMPORTED targets, which are used in the project for link.
Its package file includes the script(s), which is created by install(EXPORT) command and filled according to install(TARGETS ... EXPORT ...) command. This included script uses IMPORTED targets, but doesn't define them.
The project's package file forgets to use find_package, or, better, find_dependency for define the IMPORTED target for the included scripts.
If you don't want to fix the (other) project's package file, then the most direct solution is to add missed find_package into your own project:
# Hack: This will define IMPORTED targets, needed for gRPC project, but not defined by it.
find_package(Protobuf REQUIRED)
# Now perform the original 'find_package' call.
find_package(gRPC CONFIG REQUIRED)
Actually, gRPCConfig.cmake package file was intended to contain the call find_package(Protobuf). Its template cmake/gRPCConfig.cmake.in is following:
# Module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules)
# Depend packages
#_gRPC_FIND_ZLIB#
#_gRPC_FIND_PROTOBUF#
#_gRPC_FIND_SSL#
#_gRPC_FIND_CARES#
#_gRPC_FIND_ABSL#
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
and on substitution the variable _gRPC_FIND_PROTOBUF should emit the following code:
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})
endif()
(the variable should be set in cmake/protobuf.cmake).
But something goes wrong, and the resulted /usr/lib64/cmake/grpc/gRPCConfig.cmake contains the empty variable's substitution:
# Module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules)
# Depend packages
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
Let take /SLAM/vox_ws as package A,
take kimera_semantic_ws as package B,
they are all ROS projects.
If I use CLion to load CMakeLists.txt of the package A in /home/lzw/resplendent_code/SLAM/vox_ws/src/voxgraph/voxgraph/CMakeLists.txt
it will output the error at package B like
CMake Error at /home/lzw/resplendent_code/kimera_semantic_ws/devel/share/catkin_simple/cmake/catkin_simple-extras.cmake:38 (find_package):
By not providing "Findcblox.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "cblox", but
CMake did not find one.
Could not find a package configuration file provided by "cblox" with any of
the following names:
cbloxConfig.cmake
cblox-config.cmake
Add the installation prefix of "cblox" to CMAKE_PREFIX_PATH or set
"cblox_DIR" to a directory containing one of the above files. If "cblox"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:7 (catkin_simple)
-- Configuring incomplete, errors occurred!
See also "/home/lzw/resplendent_code/SLAM/vox_ws/src/voxgraph/voxgraph/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/home/lzw/resplendent_code/SLAM/vox_ws/src/voxgraph/voxgraph/cmake-build-debug/CMakeFiles/CMakeError.log".
I think it is very weird.
I'm trying to link SDL2_net (SDL_net 2.0) to my project via CMake, but after searching around I've yet to find a solution. My CMakeLists.txt currently looks like this:
1 cmake_minimum_required (VERSION 3.7)
2 project (SDL_net_test)
3 include (FindPkgConfig)
4 include (FindSDL_net)
5
6 pkg_search_module (SDL2 REQUIRED sdl2)
7 pkg_search_module (SDL_NET REQUIRED sdl2_net)
8
9 include_directories (${SDL2_INCLUDE_DIRS} ${SDL_NET_INCLUDE_DIRS})
10
11 add_executable (SDL_net_test main.cpp)
12 target_link_libraries (SDL_net_test ${SDL2_LIBRARIES} ${SDL_NET_LIBRARIES})
However, when I attempt to run CMake it gives me the following error(s):
-- Could NOT find SDL_net (missing: SDL_NET_LIBRARIES SDL_NET_INCLUDE_DIRS)
-- Checking for one of the modules 'sdl2_net'
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:659 (message):
None of the required 'sdl2_net' found
Call Stack (most recent call first):
CMakeLists.txt:7 (pkg_search_module)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
SDL_NET_INCLUDE_DIR (ADVANCED)
used as include directory in directory /home/neboula/Programming/sandbox/sdl2_net
used as include directory in directory /home/neboula/Programming/sandbox/sdl2_net
used as include directory in directory /home/neboula/Programming/sandbox/sdl2_net
SDL_NET_LIBRARY (ADVANCED)
linked by target "SDL_net_test" in directory /home/neboula/Programming/sandbox/sdl2_net
-- Configuring incomplete, errors occurred!
See also "/home/neboula/Programming/sandbox/sdl2_net/build/CMakeFiles/CMakeOutput.log".
I have installed the SDL2_net-devel package from my package manager (dnf on Fedora 29), and I've successfully linked SDL2 and SDL2_image previously basing it on this answer, which worked brilliantly. I also found this, but I'm not entirely sure how to use it. How should I go about this?
Since the person who provided an answer only posted a comment about it, I'll put it down here myself.
The solution was seemingly very simple: I had written pkg_search_module (SDL_NET REQUIRED sdl2_net), while it was supposed to be pkg_search_module (SDL_NET REQUIRED SDL2_net).
To easily integrate the SDL2 library and other related libraries (SDL2_net, SDL2_mixer, ...), I developed modern cross-platform CMake modules that can be used as follows:
Clone SDL2 CMake modules inside our project:
git clone https://github.com/aminosbh/sdl2-cmake-modules cmake/sdl2
Add the following lines in your main CMakeLists.txt
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
find_package(SDL2 REQUIRED)
find_package(SDL2_net REQUIRED)
target_link_libraries(${PROJECT_NAME} SDL2::Main SDL2:Net)
You can even specify a custom path to find the SDL2, SDL2_net, ... useful specially on Windows.
cmake .. -DSDL2_PATH="/path/to/sdl2" -DSDL2_NET_PATH="/path/to/sdl2-net"
For sure, you should not forgot to install the specific packages:
# Fedora/RPM
sudo yum install SDL2-devel SDL2_net-devel
# Debian/Ubuntu
sudo apt install libsdl2-dev libsdl2-net-dev
I have this problem.
CMake Error at CMakeLists.txt:14 (find_package): By not providing
"FindTBB.cmake" in CMAKE_MODULE_PATH this project has asked CMake to
find a package configuration file provided by "TBB", but CMake did
not find one.
I could not find a package configuration file provided by "TBB" with any of the following names:
TBBConfig.cmake
tbb-config.cmake
Add the installation prefix of "TBB" to CMAKE_PREFIX_PATH or set
"TBB_DIR" to a directory containing one of the above files. If
"TBB" provides a separate development package or SDK, be sure it has
been installed.
how can i fix this?
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.9)
project(deneme)
set(CMAKE_CXX_STANDARD 11)
include("C:/yunus/Git/inteltbb/tbb/cmake/TBBBuild.cmake")
tbb_build(TBB_ROOT "C:/yunus/Git/inteltbb/tbb" CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
add_executable(deneme main.cpp ToDo.cpp ToDo.h)
TBB does not come by default with a FindTBB.cmake module so the guidelines in the error message are a bit misleading.
If your project provides the corresponding FindTBB.cmake module you need to add the path to it and the path to the TBB installation to your CMake call, i.e.
cmake . -G "<your generator here>" -DTBB_DIR=<path to TBB installation> -DCMAKE_PREFIX_PATH=<path to FindTBB.cmake>
Otherwise you need to download a suitable FindTBB.cmake module e.g. https://github.com/schuhschuh/cmake-basis-modules/blob/develop/FindTBB.cmake
This one uses TBB_ROOT instead of TBB_DIR.
Edit:
Try the binary package integration of TBB first.
Comment the include(...) and the tbb_build(...) command and add
target_link_libraries(deneme ${TBB_IMPORTED_TARGETS})
to your CMakeLists.txt after the add_executable call. Then call
cmake . -G "<your generator here>" -DCMAKE_PREFIX_PATH=<path to your TBB installation>
I tried everything like:
Configure environment variable
Make fresh build
Re-install BOOST from source
sudo apt-get install libboost-all-dev
But still getting following Errors:
CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1131 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:147 (find_package)
CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1131 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Source code directory for boost: /usr/local/src/boost_1_45_0
Boost Library path: /usr/local/lib
Boost Header file: /usr/local/include/boost
Here is bashrc file:
BOOST_ROOT="/usr/local/src/boost_1_45_0"
Boost_LIBRARY_DIRS="/usr/local/lib"
BOOST_INCLUDEDIR="/usr/local/src/boost_1_45_0"
How to solve these Errors? Am i missing something?
Edit:
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DBOOST_ROOT=/usr/local/src/boost_1_45_0 -DBOOST_INCLUDEDIR=/usr/local/include/boost -DBOOST_LIBRARYDIR=/usr/local/lib -DPYTHON_LIBRARIES=/usr/local/lib/python2.7 -DPYTHON_INCLUDE_DIRS=/usr/include/python2.7 -DCMA-DRDK_BUILD_PYTHON_WRAPPERS=
Try to complete cmake process with following libs:
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev
I'm using this to set up boost from cmake in my CMakeLists.txt. Try something similar (make sure to update paths to your installation of boost).
SET (BOOST_ROOT "/opt/boost/boost_1_57_0")
SET (BOOST_INCLUDEDIR "/opt/boost/boost-1.57.0/include")
SET (BOOST_LIBRARYDIR "/opt/boost/boost-1.57.0/lib")
SET (BOOST_MIN_VERSION "1.55.0")
set (Boost_NO_BOOST_CMAKE ON)
FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)
if (NOT Boost_FOUND)
message(FATAL_ERROR "Fatal error: Boost (version >= 1.55) required.")
else()
message(STATUS "Setting up BOOST")
message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
message(STATUS " Library - ${Boost_LIBRARY_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif (NOT Boost_FOUND)
This will either search default paths (/usr, /usr/local) or the path provided through the cmake variables (BOOST_ROOT, BOOST_INCLUDEDIR, BOOST_LIBRARYDIR). It works for me on cmake > 2.6.
I got the same error the first time I wanted to install LightGBM on python (GPU version).
You can simply fix it with this command line :
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev
the boost libraries will be installed and you'll be fine to continue your installation process.
seems the answer is in the comments and as an edit but to clarify this should work for you:
export BUILDDIR='your path to build directory here'
export SRCDIR='your path to source dir here'
export BOOST_ROOT="/opt/boost/boost_1_57_0"
export BOOST_INCLUDE="/opt/boost/boost-1.57.0/include"
export BOOST_LIBDIR="/opt/boost/boost-1.57.0/lib"
export BOOST_OPTS="-DBOOST_ROOT=${BOOST_ROOT} -DBOOST_INCLUDEDIR=${BOOST_INCLUDE} -DBOOST_LIBRARYDIR=${BOOST_LIBDIR}"
(cd ${BUILDDIR} && cmake ${BOOST_OPTS} ${SRCDIR})
you need to specify the arguments as command line arguments or you can use a toolchain file for that, but cmake will not touch your environment variables.
I just want to point out that the FindBoost macro might be looking for an earlier version, for instance, 1.58.0 when you might have 1.60.0 installed. I suggest popping open the FindBoost macro from whatever it is you are attempting to build, and checking if that's the case. You can simply edit it to include your particular version. (This was my problem.)
Thanks Paul-g for your advise. For my part it was a bit different.
I installed Boost by following the Step 5 of : https://www.boost.org/doc/libs/1_59_0/more/getting_started/unix-variants.html
And then I add PATH directory in the "FindBoos.cmake", located in /usr/local/share/cmake-3.5/Modules :
SET (BOOST_ROOT "../boost_1_60_0")
SET (BOOST_INCLUDEDIR "../boost_1_60_0/boost")
SET (BOOST_LIBRARYDIR "../boost_1_60_0/libs")
SET (BOOST_MIN_VERSION "1.55.0")
set (Boost_NO_BOOST_CMAKE ON)
Long answer to short, if you install boost in custom path, all header files must in ${path}/boost/.
if you want to konw why cmake can't find the requested Boost libraries after you have set BOOST_ROOT/BOOST_INCLUDEDIR, you can check cmake install location path_to_cmake/share/cmake-xxx/Modules/FindBoost.
cmake which will find Boost_INCLUDE_DIR in boost/config.hpp in BOOST_ROOT. That means your boost header file must in ${path}/boost/, any other format (such as ${path}/boost-x.y.z) will not be suitable for find_package in CMakeLists.txt.
I had the same issue inside an alpine docker container, my solution was to add the boost-dev apk library because libboost-dev was not available.