Use CMake binares to build cpp projects without installing CMake - cmake

I want to use specific version of CMake 3.19.0 for Ubuntu 14.04 (32-bits) without installing CMake (use only binaries).
I tried to build CMake 3.19.0 on my test machine. It builded and installed successfully. In install_manifest.txt I see lot of files that were installed on my test system.
So, I tried to copy only installed binaries from /usr/local/bin/ (this is default path where CMake binaries were installed) and paste it to another machine that doesn't know about CMake. I paste 3 binaries: cmake, ctest, cpack to /usr/local/bin/.
If I run which cmake it shows path:
/usr/local/bin/cmake
If I run cmake --verison it shows:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/share/cmake-3.19
cmake version 3.19.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
It looks like CMake needs some modules that I haven't copied yet. I tried to build my cpp project and it shows me:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/share/cmake-3.19
CMake Error: Error executing cmake::LoadCache(). Aborting.
What are the minimum required modules needed for stable building? And where I should copy it?

Just copied builded Modules and Templates directories from cmake-3.19.0 build directory to /usr/local/share/cmake-3.19

Related

cmake version in catkin_make different from global cmake version?

I'm trying to build some package in ROS using catkin.
When I run catkin_make in the top level directory, I got complaint about cmake version:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/ignition-math4/ignition-math4-config.cmake:26 (cmake_minimum_required):
CMake 3.5.1 or higher is required. You are running version 3.3.2
Then I updated my cmake version, and also modified the path. I verified that the version of cmake is now 3.15:
~/catkin_ws$ cmake --version
cmake version 3.15.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
when I go back and try catkin_make again, the problem still remains.
I suppose that catkin has defined its own path or environment variable somewhere and are using cmake from a different place, but I couldn't figure out how to change it. Any suggestions? Thanks in advance.
--Kevin
you could remove .catkin_tools from your working directory, and redo the initialization of catkin:
source /opt/ros/<your-ros-development>/setup.bash
and
catkin init
if your environment setup is correct, that should do the trick.

CMake find_package not working for Eigen?

I'm currently developing a Kalman Filtering library using Eigen and I've successfully gotten it working on my development Mac. Now I'm trying to set it up with Travis CI and CMake is having trouble with finding the package. First I sudo apt install libeigen3-dev and then attempt to run cmake with the following configuration:
cmake_minimum_required(VERSION 3.0)
project(KFilter VERSION 0.1.0)
find_package (Eigen3 REQUIRED NO_MODULE)
add_library(KFilter KFilter.cpp)
target_link_libraries(KFilter Eigen3::Eigen)
This builds just fine on my Mac, but in Travis CI it errors out with the following:
CMake Error at CMakeLists.txt:5 (add_library):
Target "KFilter" links to target "Eigen3::Eigen" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Why is would I be getting this error at line 5 when the find_package seems to be successful? I'm following this guide from the Eigen website.
Travis CI is running Ubuntu 16.04 with CMake 3.12 and the Eigen3 debian package, while my Mac is running CMake 3.13 with Eigen installed through homebrew. I'm really confused as to why CMake is behaving differently.
You don't mention which version of Eigen3 is being used in each case.
It looks like between Eigen3 3.2 and 3.3 it changed from using FindEigen3.cmake to Eigen3Config.cmake. This changed how to include Eigen3 into a project and in 3.3 it uses Eigen3::Eigen3.
But as it turns out on Ubuntu 16.04 the package is libeigen3-dev (3.3~beta1-2) and 3.3 beta versions didn't export Eigen3::Eigen3 instead it contains:
add_definitions ( ${EIGEN3_DEFINITIONS} )
include_directories ( ${EIGEN3_INCLUDE_DIRS} )
So just remove target_link_libraries(KFilter Eigen3::Eigen) and it should be fine.
What worked for me using Ubuntu 16.04 was to remove the target_link_libraries(KFilter Eigen3::Eigen) and change in my source file the following line #include <eigen3/Eigen/Dense>

pip3 gives CMake Error in CMakeLists.txt

I am trying to run pip3 install face_recognition. But it gives below problem for cmake.
Building for: NMake Makefiles
CMake Error in CMakeLists.txt:
Generator
NMake Makefiles
does not support platform specification, but platform
x64
was specified.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
pip3 version is 9.03, Python 3.7 and cmake 3.12.0-rc3. I don't have Visual studio. I don't have admin rights on my PC. Hence I downloaded the all the above packages, extracted and added their bin dir in path. Similar way I have installed MinGW and added its bin directory in path. Nothing is working. Couple of forums talk about removing CMakeCache.txt. I am struggling to find CMakeCache.txt. I think pip command is downloading the package, extracting in temp directory and compiling it. When compilation fails it delete the extracted content. Not sure. Please help
After carefully studying a logs, I realized it's Dlib installation a giving problem. After lots of search, I got the url https://www.learnopencv.com/install-opencv-3-and-dlib-on-windows-python-only. It suggest to use Anaconda. I installed the Anaconda and followed the instruction from article and discussions. It worked perfectly for me.

cmake failed to configure due to GL.h

I am trying to build cmake 3.10.2 from source.
I already have cmake installed but an older version so I am running
cmake .
make
make install
but the machine I am on doesn't have gl and cmake fails on missing gl/gl.h is there a way to not require gl.h?

Unable to build libwebsockets library due to CMake missing OpenSSL

I am trying to build libwebsockets on Windows 10 using CMake and MinGW. The library requires OpenSSL.
Environment Variables:
OPENSSL_CONF=C:\Program Files (x86)\OpenSSL-Win32\bin\openssl.cfg
OPENSSL_ROOT_DIR=C:\Program Files (x86)\OpenSSL-Win32
I'm using this to build:
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=D:/MinGW -DOPENSSL_LIBRARIES="C:\Program Files (x86)\OpenSSL-Win32\lib" -DOPENSSL_CONF="C:\Program Files (x86)\OpenSSL-Win32\openssl.cfg" -DOPENSSL_INCLUDE_DIR="C:\Program Files (x86)\OpenSSL-Win32\include" ..\
The error I get is:
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found version "1.1.0")
I downloaded the OpenSSL binaries from a community build and have used both 64 and 32 versions.
I've even modified the CMake file to confirm the variables were being passed in.
This was a problem with the version of CMake I was using. I upgraded from CMake 3.3.x to 3.6.2 and the build is now successful.