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"
Related
I'm trying to build and install LLVM 9.0.0 on my Windows 10 machine.
I have CMake and Visual Studio 2019 with C++ tools installed, and using the following strategy to build (and install) LLVM using CMake:
> cmake . -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_INCLUDE_TESTS=OFF
> cmake --build . --config Release --target INSTALL -j8
The following error occurs on the first command:
Generating libLLVM is not supported on MSVC
Note that I'm required to build LLVM dynamically otherwise it won't link. Any ideas?
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=/
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.
CMake comes with a cross-platform way to compile projects which is cmake --build .. Is there a similar command to install a project? I'm looking for something that translates to make install on Unix but also works on Windows.
cmake --build . --target install
is there any specific reason why CMake doesn't find windres.exe from MingW as the RC compiler? The MingW dir is in my PATH variable, windres.exe does exist.
I always have to set the CMAKE_RC_COMPILER variable by hand to windres.exe in the cmake GUI.
After googling quite a while now, I only found out that more people have this problem, but I never found any real solution...
I have the latest cmake (2.8.5).
Only thing I found was: http://public.kitware.com/Bug/view.php?id=4068 but the things describes there don't work for me.
One workaround is to edit the CMakeCache.txt
//RC compiler.
CMAKE_RC_COMPILER:FILEPATH=g:/dev/Rtools/MinGW/bin/windres.exe
(or whatever the path to your MinGW install happens to be)
Then run cmake again
For MinGW, use cmake -G "MinGW Makefiles" source-directory/
If you have MSYS installed, use cmake -G "MSYS Makefiles" source-directory/
No plumbing needed.
Many bug fixes have been merged into CMake related to "windres" since the 2.8.5 release.
Try using CMake 2.8.12 or later: it should work with windres "out of the box" at this point.