CLion CMake problems - cmake

I am having a problem when loading CMake on CLion. I'm attempting to setup my proper environment for Arduino programming.
I'm probably missing something obvious, but I was unable to find a functional solution to this. Could anyone give me a hint as to what is causing the following errors?
Error:The CMAKE_C_COMPILER:
avr-gcc
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
Error:The CMAKE_CXX_COMPILER:
avr-g++
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

I got it working following the steps given in the arduino-cmake repo. If you're working on windows make sure you have the arduino sdk installed. And set the correct path in to the sdk.
If you're working on linux make sure you have all the correct dependencies installed as specified in the readme.md in the github repo.
And last but not least, ensure that de cmake directory and toolchain file are present in the project folder.
See
https://github.com/arduino-cmake/arduino-cmake
For proper instructions.

Related

cmake not finding package configuration file

I am using Qt Creator as IDE and MSVC 2019.
I built and installed the pagmo library from the source. Now I am trying to use it for my project.
Even though the installation seems fine, when I try to load it I get strange errors, telling me that "pagmo" is not found. In particular:
error:
By not providing "FindPagmo.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Pagmo",
but CMake did not find one.
Could not find a package configuration file provided by "Pagmo" with any
of the following names:
PagmoConfig.cmake
pagmo-config.cmake
Add the installation prefix of "Pagmo" to CMAKE_PREFIX_PATH or set
"Pagmo_DIR" to a directory containing one of the above files. If
"Pagmo" provides a separate development package or SDK, be sure it has
been installed.
In my CMakeLists.txt I have set the following command:
find_package(Pagmo REQUIRED)
Now, as far as I know FindPagmo.cmake does not exist, BUT I am giving as input parameter Pagmo_DIR, which contains the file pagmo-config.cmake. I can't understand why CMake is not finding it. I also tried to set CMAKE_MODULE_PATH to the same folder but nothing changed.
Does anybody have suggestions on how to solve this problem?
I am setting pagmo directory as follows:
-DPagmo_DIR = C:\Lib\pagmo\install\debug\lib\cmake\pagmo
in that folder I have the following files:
Findpagmo_IPOPT.cmake;
pagmo_export.cmake;
pagmo_export-debug.cmake;
pagmo-config.cmake;
pagmo-config-version.cmake;
PagmoFindBoost.cmake

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})".

How to instruct "find_package" to find a package installed in a user-specified location?

I installed a software package using CMake, on a customized location, with the command line below
cmake .. -DCMAKE_INSTALL_PREFIX=../install
Now CMake can no more find the package with the find_package. The error message suggests me to specify either CMAKE_MODULE_PATH or CMAKE_PREFIX_PATH.
I tried to specify the installation path using
cmake .. -DCMAKE_MODULE_PATH=../install
It did not work. But the following worked:
cmake .. -DCMAKE_PREFIX_PATH=../install
Question: In general, what would be the sound and reliable way to specify the path for "find_package" to work correctly for finding a package installed to a user-specified location?

CMake could not find the VTKConfig.cmake

I'm trying to compile a program in CMake but I'm getting this error.
By not providing "FindVTK.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "VTK", but
CMake did not find one.
Could not find a package configuration file provided by "VTK" (requested
version 6.1) with any of the following names:
VTKConfig.cmake
vtk-config.cmake
I can't find the relevant files (VTKConfig.cmake or vtk-config.cmake) on the machine but do have VTKConfig.cmake.in (which also doesn't work).
Does anyone know where I can download the file from, or what I might be doing wrong.
It seems like you just have the VTK source code but haven't built it yet. VTKConfig.cmake.in is a template used by CMake to generate the VTKConfig.cmake file in the build and install directory. Look at http://www.vtk.org/Wiki/VTK/Building to see how to build VTK.
When you have successfully built VTK you can give CMake a hint where to look for VTK with the VTK_DIR-parameter:
cmake -DVTK_DIR=/path/to/vtk/build-directory /path/to/your/source-directory
If you have successfully built VTK, you would end up with a VTK-Release-build folder containing all the build files, one of which is VTKConfig.cmake. Your program is not able to find this file. You just need to set an environment variable named VTK_DIR before running your program. You can do so by running:
export VTK_DIR=/path/to/VTK-Release-build/
"FindVTK.cmake"the file of cmake is made in build directry.
please add this Path. export VTK_DIR=/path/VTK-Release-version/build

llvm's cmake integration

I'm currently building a compiler/interpreter in C/C++.
When I noticed LLVM I thought it would fit greatly to what I needed and so I'm trying to integrate LLVM in my existing build system (I use CMake).
I read this bout integration of LLVM in CMake. I copy and pasted the example CMakeLists.txt, changed the LLVM_ROOT to ~/.llvm/ (that's where I downloaded and build LLVM and clang) and it says it isn't a valid LLVM-install. Best result I could achieve was the error message "Can't find LLVMConfig" by changing LLVM_ROOT to ~/.llvm/llvm.
My ~/.llvm/ folder looks like this:
~/.llvm/llvm # this folder contains source files
~/.llvm/build # this folder contains object, executable and library files
I downloaded LLVM and clang via SVN. I did not build it with CMake.
Is it just me or is something wrong with the CMakeLists.txt?
This CMake documentation page got rotted, but setting up CMake for LLVM developing isn't different from any other project. If your headers/libs are installed into non-standard prefix, there is no way for CMake to guess it.
You need to set CMAKE_PREFIX_PATH to the LLVM installation prefix or CMAKE_MODULE_PATH to prefix/share/llvm/cmake to make it work.
And yes, use the second code snippet from documentation (under Alternativaly, you can utilize CMake’s find_package functionality. line).