I have installed vcpkg according to the instructions provided here. I installed the libraries I wanted (in this case fmt and boost), then created a simple new project in KDevelop which runs just fine. Then to add my libraries to the project I added -DCMAKE_TOOLCHAIN_FILE=/VCPKG_LOCATION/vcpkg/scripts/buildsystems/vcpkg.cmake in the "Configure CMake settings", where there is an "Extra arguments field", of KDevelop (Right click on Project folder and then "Open Configuration...").
Then I simply added the following to my CMakeLists.txt:
find_package(fmt REQUIRED)
and I get the following error:
By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"fmt", but CMake did not find one.
Could not find a package configuration file provided by "fmt" with
any of the following names:
fmtConfig.cmake
fmt-config.cmake
Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set
"fmt_DIR" to a directory containing one of the above files. If
"fmt" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
It seems that KDevelop is not recognizing the toolchain file (even though I can clearly see in the build log that that CMake is being called with the "-DCMAKE_TOOLCHAIN_FILE" as required). I have tried to setup the project similarly in Qt Creator which does seem to work perfectly fine.
You can install fmt package. With gcc/g++ installed,
git clone https://github.com/fmtlib/fmt.git
cd fmt
mkdir build
cd build
cmake ..
make
sudo make install
Related
I've installed Drogon using vcpkg, and in my IDE I have following error:
Package 'Drogon' not found. After installing, regenerate the CMake cache.
I am using Visual Studio 2022
vcpkg_rf.txt:
install
drogon
CMakeLists.txt:
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)
project ("Drogon Server1")
# Include sub-projects.
add_subdirectory ("Drogon Server1")
# Line below is showing the error
find_package(Drogon CONFIG REQUIRED)
target_link_libraries("Drogon Server1" PRIVATE Drogon::Drogon)
I have found this error also:
CMake Error at C:/Users/MY_USERNAME/Documents/sdk/vcpkg/scripts/buildsystems/vcpkg.cmake:829 (_find_package):
Could not find a package configuration file provided by "Drogon" with any
of the following names:
DrogonConfig.cmake
drogon-config.cmake
Add the installation prefix of "Drogon" to CMAKE_PREFIX_PATH or set
"Drogon_DIR" to a directory containing one of the above files. If "Drogon"
provides a separate development package or SDK, be sure it has been
installed.
Considering the given information:
Visual Studio 2022
-> Means CMake will default to x64 -> vcpkg will use VCPKG_TARGET_TRIPLET=x64-windows
vcpkg_rf.txt: install drogon
-> Means you use a response file to install drogon. Without specifying the triplet this is x86-windows
As such your triplet used by CMake and vcpkg doesn't agree. Consider using vcpkg in manifest mode by providing a vcpkg.json with the dependency instead of a response file. This way you won't have a discrepancy in your triplet selection
(As always chanigng this also requires to delete the cmake cache for a clean reconfigure. Furthermore don't have spaces in your target and paths; you are just asking for trouble.)
I am trying to follow the simple example for embedding python within c++ using pybind11 as found on this page. However, when trying to use cmake to build the solution, I keep getting an error that says
By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file
provided by "pybind11", but CMake did not find one.
Could not find a package configuration file provided by "pybind11"
with any of the following names:
pybind11Config.cmake
pybind11-config.cmake
I have a folder called pybindtest on my Desktop which includes CMakeLists.txt and main.cpp as described in the link above, as well as a build folder that I created. While in the build folder, I have tried the following lines to no avail (running on Powershell 7):
cmake ..
cmake .. -Dpybind11_DIR=C:/Users/ben.wolfley/Anaconda3/Library/share/cmake/pybind11/pybind11Config.cmake
cmake .. -DCMAKE_MODULE_PATH=C:/Users/ben.wolfley/Anaconda3/Library/share/cmake/pybind11
I installed pybind11 using conda install pybind11, and pybind11Config.cmake is in C:\Users\ben.wolfley\Anaconda3\Library\share\cmake\pybind11
In case someone having the same issue without Anaconda, like directly with pip pybind11 or manual clone installation, both caused problems in my case. Manual installation of pybind11 with git didn't install the cmake config pybind11Config.cmake, although there is a tools/pybind11Config.cmake.in file, that I couldn't turn into a proper pybind11Config.cmake.
Installation pybind11 global with pip solved it for me, and automatically uninstalled the manual git installation:
pip install "pybind11[global]"
which installed both pybind11 and pybind11-global with proper cmake config like Anaconda does.
Thanks to Tsyvarev for pointing me in the right direction. The following command worked:
cmake .. -G "Visual Studio 15 2017" -A x64 `
-Dpybind11_DIR=C:/Users/ben.wolfley/Anaconda3/Library/share/cmake/pybind11/
I was pointing to the .cmake file instead of the file's directory. I also had to specify the compiler in order for the code to work.
Add following to CMakeLists.txt:
```cmake
# set pybind11 dir
set(pybind11_DIR /Users/Caleb/Softwares/pybind11)
find_package(pybind11 REQUIRED)
```
here is a doc about that, but it doesn't look correct for me ,
so I've copied cmake instructions into my cmakelists.txt and it doesn't work.
it's clear why it doesn't work - because there is no one instruction how to search qt:
I suppose two cases:
some additional cmake instructions requires to set
some environment variables should be set
but nothing about that.
the instruction :
find_package(Qt5Widgets)
refers to extra cmake script from qt kit , isn't it?
I see the directory with that name (annd contains *.cmake scripts but another names) but there is no the script with this name
these are the only .cmake files with qt in names in cmake 3.6 :
cmake-3.6\Modules\DeployQt4.cmake
cmake-3.6\Modules\FindosgQt.cmake
cmake-3.6\Modules\FindQt.cmake
cmake-3.6\Modules\FindQt3.cmake
cmake-3.6\Modules\FindQt4.cmake
cmake-3.6\Modules\Qt4ConfigDependentSettings.cmake
cmake-3.6\Modules\Qt4Macros.cmake
cmake-3.6\Modules\UseQt4.cmake
===================
C:\dev\tools\CLion.RC\bin\cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug
-G "CodeBlocks - MinGW Makefiles" C:\dev\workspace\algolist.v2 CMake Warning at CMakeLists.txt:14 (find_package): By not providing
"FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked
CMake to find a package configuration file provided by "Qt5Widgets",
but CMake did not find one.
Could not find a package configuration file provided by "Qt5Widgets"
with any of the following names:
Qt5WidgetsConfig.cmake
qt5widgets-config.cmake
Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or
set "Qt5Widgets_DIR" to a directory containing one of the above
files. If "Qt5Widgets" provides a separate development package or
SDK, be sure it has been installed.
CMake Error at CMakeLists.txt:20 (target_link_libraries): Cannot
specify link libraries for target "helloworld" which is not built by
this project.
-- Configuring incomplete, errors occurred! See also "C:/dev/workspace/algolist.v2/cmake-build-debug/CMakeFiles/CMakeOutput.log".
seems it found Qt5Widgets, but absolutely not clear how it does this...
so it looks for cmake files inside Qt5Widgets folder, in Qt kit.
I can add this folder to the path but I don't think this is a valid way,
because there is a lot of subfolders with cmake files
Qt5.8 beta, built with MinGW, Win10, cmake 3.6
You need to use CMAKE_PREFIX_PATH.
For example:
cmake.exe -DCMAKE_PREFIX_PATH="C:/path/to/Qt/5.X/compiler/lib/cmake"
I'm trying to control raspberry pi camera via c++. I found api (raspicam), installed, checked. It works with an example provided by developer. Now I create my own project and got an error of CMakeLists:
CMake Error at CMakeLists.txt:3 (find_package):
By not providing "Findraspicam.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "raspicam",
but CMake did not find one.
Could not find a package configuration file provided by "raspicam" with any
of the following names:
raspicamConfig.cmake
raspicam-config.cmake
Add the installation prefix of "raspicam" to CMAKE_PREFIX_PATH or set
"raspicam_DIR" to a directory containing one of the above files. If
"raspicam" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/pi/raspicam/build/CMakeFiles/CMakeOutput.log".
And it is my CmakeLists.txt file:
make_minimum_required (VERSION 2.8)
project (raspicam_test)
find_package(raspicam REQUIRED)
add_executable (simpletest_raspicam simpletest_raspicam.cpp)
target_link_libraries (simpletest_raspicam ${raspicam_LIBS})
I just have started and already got a problem... Could you help please guys? :/
For those who used default instructions in the readme file of the raspicam (as of v 0.1.3, might differ in future):
you can also add
set(raspicam_DIR "/usr/local/lib/cmake")
to your cmake file before you use
find_package(raspicam REQUIRED)
That is when you have raspicamConfig.cmake at /usr/local/lib/cmake. If you did not have it at that directory, you can simply search your raspberry to find where it is or you can go to "build" folder in raspicam you used to install before. Then type sudo make install again, which will return "Up-to-date" message along with all a list of files and their locations, including raspicamConfig.cmake. Hope this helps to some.
This works for me.
$ brew install vcpkg
$ vcpkg install raspicam
$ vcpkg integrate install # get path
$ cmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/Cellar/vcpkg/2021.05.12/libexec/scripts/buildsystems/vcpkg.cmake ..
I wish to use PCL with Eclipse on Ubuntu. Now, that's what I did this far:
a) Installed PCL with apt-get:
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all
b) Created new project in eclipse
~/workspace/hello_pcl/
c) In above folder created src/pcd_write.cpp from this source.
d) Created following CMakeLists.txt:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(hello_pcl)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
e) Set include path /usr/include/pcl-1.7/ in project setting
My question is: What I should do now to build projects with Eclipse? Should I make the project with cmake:
cd ~/workspace/hello_pcl/build
cmake ../src
make
Or should I do something else? I'm fairly new to cmake.
I suppose I should add libraries to project setting, but didn't find on pcl page, what are names of these libraries...
EDIT:
OK, thanks to the comment I was able to create and run the hello_pcl application (I used solution from How to configure eclipse CDT for CMake), but now I have further issue. Application works, but the Eclipse code editor still underlines all PCL-dependent commands and signs them as Field [...] could not be resolved as well as includes Unresolved inclusion [...]. Strangely, #include <iostream> makrs also as unresolved. Should I include somehow PCL libraries?
I have managed to solve my problem, this is what I have done:
Basically, point from a) to d) are correct (though I have created the project not in eclipse workspace folder, but in ~/). Now is the trick: It seems, that when following typical workflow for using CMake with Eclipse CDT, indexer behaves incorrectly. Even after adding specific include path to Path and Symbols in project properties.
What is essential here, is that after creating CMakeLists.txt (maybe for start is better to set target_link_libraries for all libraries - ${PCL_LIBRARIES}), one has to build the project with (in my case):
cd ~/hello_pcl/build
cmake -G "Eclipse CDT4 - Unix Makefiles" ../src
Of course, if You want to have Debug build, You have to specify proper option.
Next step is to add project to eclipse workspace but not as a Makefile project, but as general project, that is:
File -> Import -> General -> Existing projects into workspace.
Place path to the build folder in Select root directory (~/hello_pcl/build in my case) and click Finish.
This is the moment, when indexer parses all includes. And it takes a lot of time. But after that, everything seems to work fine.