cmake MSYS Makefiles generator missing - cmake

I have cmake 3.2.3 installed via pacman. I get an error when I try to use it from a msys64 shell:
$ cmake -G "MSYS Makefiles" ..
CMake Error: Could not create named generator MSYS Makefiles
cmake --help does not list it as an available generator.
I do see there is an MSYS.cmake in /usr/share/cmake-3.2.3/Modules/Platform.
What am I missing?

Instead of installing the cmake package, I think you need to install mingw-w64-i686-cmake (or the 64-bit version mingw-w64-x86_64-cmake).

I got the exact same message when trying to run cmake in the MSYS shell. Use a MinGW Shell (for instance MinGW-w64 Win64 Shell) instead.

If you compile native Windows binaries on Linux with MinGW
The MinGW and MSYS generators are only available on Windows based distributions. See #ifdef in cmake.cxx:
#if defined(_WIN32) && !defined(__CYGWIN__)
If you're cross-compiling use one of the available MinGW toolchains. See e.g. "How to use MinGW to cross compile software for Windows" chapter in CMake's wiki.
If you compile Windows binaries on Windows with MinGW
On my Windows PC I only have one CMake installation (the normal MSI Windows Installer with CMake directory added to PATH environment), which works from standard CMD shells and from my MSYS shells.
So in this case there is no need to install a special MinGW version of CMake (like e.g. for CygWin).
But I've rebuild CMake from source with MinGW-w64 several times lately to test some performance optimizations of cmake.exe and it did not work out-of-the-box. To work around the linker errors I've added -DCMAKE_EXE_LINKER_FLAGS="-Wl,--allow-multiple-definition" like recommended here and the resulting cmake.exe still supports the "MSYS Makefiles" generator.
So yes, there is - as you have commented - most probably something wrong with the pacman build.

I guess the pacman build is just broken, so I've resolved this issue by installing the Windows version of CMake from cmake.org with the msi installer.

Related

Use CMake binares to build cpp projects without installing 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

cmake msys2, wrong install path for library

I'm on windows, tried to install EASTL, it got installed in Program Files instead of compiler's path.
Maybe I should change something in CMakeLists?
Library's CMakeLists: https://github.com/electronicarts/EASTL/blob/master/CMakeLists.txt
Commands I used:
cmake -G"MSYS Makefiles"
make
make install
It's a little tricky because MSYS2's CMake is a native Windows program that only understands Windows paths, and MSYS2 has automatic conversions of paths from POSIX-style to Windows-style that gets in the way sometimes.
These commands should work:
MSYS2_ARG_CONV_EXCL=- cmake . -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=$MSYSTEM_PREFIX
make install DESTDIR=/

Error:Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

I am using Point cloud library 1.5.1. When I run CMake 3.4.0-rc2 to build my project, it has error:
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
How do I fix this error?
This error is raised because the pkg-config utility is not available on your system.
Using PkgConfig with CMake is not a truly cross-platform solution, as Windows does not come with the pkg-config utility installed. (The PCL developers should instead use find_package() in their CMake. Perhaps, this is worth opening up a bug report on their Github.) On Linux, this is an easy fix; you can install pkg-config like this:
sudo apt-get install pkg-config
However, on Windows, the process is more involved. There are several solutions for installing pkg-config on Windows documented here. I'm not sure which most directly applies to your situation, so I suggest reading through some of those. After successfully installing the pkg-config utility on your Windows machine, clear your CMake cache, and re-run CMake. This should remove the error, and allow your build to proceed.
Install vcpkg: https://vcpkg.io/en/getting-started.html
Install pkgconf:
.\vcpkg install pkgconf
If use CMake, delete the Cache files/folders: CMakeCache.txt and CMakeFiles. After that, run the command
cmake .. -DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake
On Fedora 34, it was because of multiple pkg-config
/home/sapillai/go/bin/pkg-config
/home/sapillai/go/bin/pkg-config
/usr/bin/pkg-config
/home/sapillai/go/bin/pkg-config
I deleted the others and kept /usr/bin/pkg-config. Error was gone.

Install (build) C++ dependency for Windows using g++ with cygwin

For context I'm completely new to cmake and C++ compiling. I'm trying to compile an application only available for linux in windows using g++. That application has a 3rd party library which I need to install/build on Windows as well.
That library uses cmake. When running cmake it defaults to "Building for: Visual Studio 12" and then fails due to an issue with time.h Anyway how can I set it to use cygwins g++ instead of visual studio? Or am I misunderstanding soemthing? I also tried this to no avail:
cmake ../ -DCMAKE_CXX_COMPILER=g++
cmake ../ -DCMAKE_CXX_COMPILER:STRING=g++
Where can this setting be configured so that it will take the compiler I desire?
You need "Unix Makefiles" generator :
cmake .. -G "Unix Makefiles"

kdevelop4 and C++ requires cmake

I want to use kdevelop4 for c++ programming but when I try to run the application kdevelop4 wants cmake binary file! How can I solve this problem?
It sounds like you need to install CMake. If you are on a Linux system, aptitude install cmake (for Debian/ubuntu) or yum install cmake (for Red Hat/Fedora) should do the trick. On Windows, you may need to download and install CMake yourself.