CPack - error "Numeric user ID too large" - cmake

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.

Related

Problem with the clean target of an external project when running `catkin_make clean`

I have a lot of packages in a repository, some of my packages are installed the following way (snippet of the CMakeLists.txt file of one of my custom ROS packages):
include(ExternalProject)
ExternalProject_Add(<PACKAGE_NAME>
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/<SOME_PATH>
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) DESTDIR=${<PACKAGE>_DESTDIR} install
)
This works perfectly when compiling with catkin_make, but if I try to run the clean target with catkin_make clean, the projects I installed with external are not cleaned. This results in problems when compiling again with catkin_make.
Is there any way to solve this issue? I read all the source code for catkin_make but making the clean target seems to be done entirely by cmake.
If you want to have the external project be built again and again (and cleaned) as part of your project then please include it using add_subdirectory instead of ExternalProject_Add
If you use add_subdirectory to include it as part of your build system, then when you call catkin_make clean, it will be cleaned

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!

How to use CMake to install

I can build my projects successfully with CMake, but can I use it to install the results?
With Make I add the target install and call that from the command line. I cannot figure out if this is possible with CMake.
The final goal is to install a static library, dynamic library and corresponding header files in a platform-portable way. How I imagine it would work: On Linux, copy to /usr/include and /usr/lib. On Windows it would probably be a user-provided folder with an include and lib folder.
The install rule suggests that something like this is possible. But how do I actually use it?
Currently I do the following:
mkdir build
cd build
cmake ..
cmake --build .
Here I would expect to do something like this:
cmake --install .
You can use the command cmake --build . --target install --config Debug for installation.
CMake's build tool mode supports further arguments that are of interest in this case.
You can select the target to build by --target option, the configuration to build by --config option, and pass arguments to the underlying build tool by means of the -- option. See the documentation (Build Tool Mode) for the build-tool-mode.
In CMake 3.15 and newer, you can use the simpler cmake --install command to Install a Project:
cmake --install . --config Debug
It additionally supports --prefix, --component and --strip.
You can use the install command on your CMakeLists that will generate installation rules for your project. A basic example is shown bellow but check the cmake documentation if you need something more complex.
project (Test)
add_executable(test main.cpp)
install(TARGETS test DESTINATION bin)
Then after generate the makefiles you can ust type sudo make install and the test application will be installed on system bin folder.

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.

For CMake's “install”, what does the CONFIGURATIONS argument do?

I don't know what the CONFIGURATIONS argument of CMake's install command does. When I use CONFIGURATIONS with debug or release in installing files, no file gets installed. What happened?
Can someone explain it in more detail. It will be best if you give me some examples.
P.S. This is not the same as: For CMake's "install" command, what can the COMPONENT argument do?
From the docs:
The CONFIGURATIONS argument specifies a list of build configurations for which the install rule applies (Debug, Release, etc.).
So for example, consider the following CMakeListst.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(Test)
add_executable(MyTest main.cc)
install(TARGETS MyTest DESTINATION bin CONFIGURATIONS Release)
This means that
cmake --build . --target install --config Release
will place the executable MyTest (or MyTest.exe) in ${CMAKE_INSTALL_PREFIX}/bin, and
cmake --build . --target install --config Debug
won't install anything.