Submodule tries to find a package which is not installed but rather another submodule - cmake

I'm trying to configure a CMake project which uses the git submodule https://github.com/hungpham2511/toppra. That submodule requires the Eigen3 library to work, so in its CMakeLists.txt there is find_package (Eigen3 REQUIRED).
I could simply install the Eigen3 library and CMake would find it (I tried this, it worked). However, my CMake project should not depend on any preinstalled libraries. Moreover, installing Eigen3 makes little sense, since it is a header-only library.
My goal is to include Eigen3 as another submodule and let toppra know where to find it.
I tried to provide Eigen3_DIR directly to toppra's CMakeLists.txt:
set (Eigen3_DIR "${PROJECT_SOURCE_DIR}/eigen" CACHE STRING)
I also tried:
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/eigen")
list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/eigen")
But CMake keeps telling:
1> [CMake] CMake Error at toppra/cpp/CMakeLists.txt:38 (find_package):
1> [CMake] By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has
1> [CMake] asked CMake to find a package configuration file provided by "Eigen3", but
1> [CMake] CMake did not find one.
1> [CMake]
1> [CMake] Could not find a package configuration file provided by "Eigen3" with any
1> [CMake] of the following names:
1> [CMake]
1> [CMake] Eigen3Config.cmake
1> [CMake] eigen3-config.cmake
1> [CMake]
1> [CMake] Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
1> [CMake] "Eigen3_DIR" to a directory containing one of the above files. If "Eigen3"
1> [CMake] provides a separate development package or SDK, be sure it has been
1> [CMake] installed.
However, there is nothing like FindEigen3.cmake in the Eigen3 library, unless - and this is important - Eigen3 is installed on the system. In that case, FindEigen3.cmake is created and put in the installation directory of the Eigen3 library.

Related

How to add the cmake compiler path(generator) to run the catkin_make command in ROS?

I am trying to work with the Robot Operating System (ROS Melodic) on Windows 10 system, following the procedure from the ROS website.
http://wiki.ros.org/Installation/Windows
When I try to create a workspace (/catkin_ws/src) and run the catkin_make,
I run into different errors viz., CMAKE_C_COMPILER, CMAKE_CXX_COMPILER paths.
So I tried to run cmake --help to find the list of generators available, so as to give the aforementioned path of a compiler. This again creates new errors stating No CMAKELists.txt found.
I am a newbie to programming and I don't get any of these.
Can anyone explain why we need this compiler path, generator, etc to build this workspace and how to run ROS successfully on Windows?
Thanks in advance for your support.
C:\opt\catkin_ws>cmake -G "NMAKE Makefiles" CMake Error: Could not
create named generator NMAKE Makefiles
C:\opt\catkin_ws>cmake -G "MSYS Makefiles" CMake Error: CMake was
unable to find a build program corresponding to "MSYS Makefiles".
CMAKE_MAKE_PROGRAM is not set. You probably need to select a
different build tool. CMake Error: CMake was unable to find a build
program corresponding to "MSYS Makefiles". CMAKE_MAKE_PROGRAM is not
set. You probably need to select a different build tool. CMake Error:
CMAKE_C_COMPILER not set, after EnableLanguage CMake Error:
CMAKE_CXX_COMPILER not set, after EnableLanguage CMake Error: CMAKE_AR
was not found, please set to archive program.
-- Configuring incomplete, errors occurred!

Building gtest on msys2 fails in install, similar problem on other packages

When trying to install google test on MSYS2, I use:
cmake -G"MSYS Makefiles" ..
make
This works, the code is generated with no errors. Then, to install:
make install
This unfortunately, does not work. There seems to be a common problem, other packages have similar issues.
-- Installing: C:/Program Files/googletest-distribution/include
CMake Error at googlemock/cmake_install.cmake:31 (file):
file INSTALL cannot make directory "C:/Program
Files/googletest-distribution/include": No such file or directory
Call Stack (most recent call first):
cmake_install.cmake:32 (include)
Is this a permissions problem? I tried sudo, but that does not exist on msys2.
The line number 31 of the error seems wrong, that's a comment:
if(NOT CMAKE_INSTALL_LOCAL_ONLY)
# Include the install script for each subdirectory.
include("D:/git/extcode/googletest/build/googlemock/cmake_install.cmake")
endif()
line 32 is the include, which refers to d:,not c:, so I do not understand the message being generated?

CPack - error "Numeric user ID too large"

I'm still new to CMake/CPack tools. This is a short example of my problem with CPack - the real project is much-much bigger. My CMakeLists.txt file is below:
cmake_minimum_required(VERSION 3.9)
project(tm0001)
set(CMAKE_CXX_STANDARD 11)
add_executable(${PROJECT_NAME} tm0001.cpp)
set(CPACK_PACKAGE_CONTACT "HEKTO")
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_GENERATOR "DEB")
include(CPack)
It's not important what is in the tm0001.cpp file - it may be just a simple Hello World program. I'm trying to generate a deb-file for this project but getting an error:
hekto#ubuntu:~/tm0001/build$ make package
Scanning dependencies of target tm0001
[ 50%] Building CXX object CMakeFiles/tm0001.dir/tm0001.cpp.o
[100%] Linking CXX executable tm0001
[100%] Built target tm0001
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: tm0001
CPack: - Install project: tm0001
CPack: Create package
CPack Error: Error creating debian package:
#top level directory: /home/hekto/tm0001/build/_CPack_Packages/Linux/DEB
#file: tm0001-1.0.0-Linux.deb
#error:archive_write_header: Numeric user ID too large
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: tm0001
make: *** [package] Error 1
What's the meaning of this Numeric user ID too large message? Where is it from? How to get rid of it?
(CMake/CPack version is 3.11.3)
This is a now-fixed bug in CMake 3.10 and 3.11. It has been fixed in 3.12. Either use CMake 3.9 or earlier, or CMake 3.12 or later.

CMake fails to find packages after removing conda

I removed conda by following option A in the documentation, i.e. I simply removed the
~/anaconda3 directory and got rid of the relevant line in my ~.bashrc. However, when I call cmake in a different project of mine, cmake still tries to link to libraries installed with anaconda:
$ cmake ..
CMake Error at /usr/share/cmake-3.9/Modules/FindBoost.cmake:1247 (file):
file STRINGS file "/home/USERNAME/anaconda3/include/boost/version.hpp"
cannot be read.
Call Stack (most recent call first):
dbklib/CMakeLists.txt:5 (find_package)
-- Boost version: 0.0.0
-- DBKLIB:
CMake Error at pydbk/pybind11/tools/FindPythonLibsNew.cmake:95 (message):
Python config failure:
Call Stack (most recent call first):
pydbk/pybind11/tools/pybind11Tools.cmake:16 (find_package)
pydbk/pybind11/CMakeLists.txt:33 (include)
How do I get rid of anaconda completely? Can I still somehow run the anaconda-clean tool without having conda?
After modifying installed packages set (especially after removing the package), when rebuild CMake project it is needed to clean CMake cache of that project, so CMake will recheck results of previous searching of packages.
CMake cache may be cleared by removing CMakeCache.txt file from build directory, or by completely cleaning the build directory.

How to install Cmake C compiler and CXX compiler

I need some help compiling this project with cmake. Here is the error message.
$ ./build_avida
-- Building for: NMake Makefiles
CMake Warning at CMakeLists.txt:1 (PROJECT):
To use the NMake generator, cmake must be run from a shell that can use the
compiler cl from the command line. This environment does not contain
INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
work.
CMake Error: CMake was unable to find a build program corresponding to "NMake Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:C:/Users/Desk/Dropbox/2012-2013/BCB504/AvidaProject/avidagit/avida/CMakeFiles/2.8.10.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:C:/Users/Desk/Dropbox/2012-2013/BCB504/AvidaProject/avidagit/avida/CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
make: *** No rule to make target `install'. Stop.
Try to install gcc and gcc-c++, as Cmake works smooth with them.
RedHat-based
yum install gcc gcc-c++
Debian/Ubuntu-based
apt-get install cmake gcc g++
Then,
remove 'CMakeCache.txt'
run compilation again.
Even though I had gcc already installed, I had to run
sudo apt-get install build-essential
to get rid of that error
The approach I use is to start the "Visual Studio Command Prompt" which can be found in the Start menu. E.g. my visual studio 2010 Express install has a shortcute Visual Studio Command Prompt (2010) at Start Menu\Programs\Microsoft Visual Studio 2010\Visual Studio Tools.
This shortcut prepares an environment by calling a script vcvarsall.bat where the compiler, linker, etc. are setup from the right Visual Studio installation.
Alternatively, if you already have a prompt open, you can prepare the environment by calling a similar script:
:: For x86 (using the VS100COMNTOOLS env-var)
call "%VS100COMNTOOLS%"\..\..\VC\bin\vcvars32.bat
or
:: For amd64 (using the full path)
call C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat
However:
Your output (with the '$' prompt) suggests that you are attempting to run CMake from a MSys shell. In that case it might be better to run CMake for MSys or MinGW, by explicitly specifying a makefile generator:
cmake -G"MSYS Makefiles"
cmake -G"MinGW Makefiles"
Run cmake --help to get a list of all possible generators.
Those errors :
"CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage"
means you haven't installed mingw32-base.
Go to http://sourceforge.net/projects/mingw/files/latest/download?source=files
and then make sure you select "mingw32-base"
Make sure you set up environment variables correctly in PATH section.
"C:\MinGW\bin"
After that open CMake and Select Installation --> Delete Cache.
And click configure button again. I solved the problem this way, hope you solve the problem.