I am trying to compile this (quite complex) piece of code with cmake and MinGW in Windows:
#include <iostream>
int main()
{
std::cout << "Test" << std::endl;
return 0;
}
This is the CMakeLists.txt
file (which works correctly in Linux):
cmake_minimum_required(VERSION 2.6)
SET(CMAKE_C_COMPILER path/to/gcc)
SET(CMAKE_CXX_COMPILER path/to/g++)
project(cmake_test)
add_executable(a.exe test.cpp)
With the command:
cmake -G"MinGW Makefiles" .
I get these errors:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (MESSAGE):
sh.exe was found in your PATH, here:
C:/MinGW/msys/1.0/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)
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: Could not find cmake module file:C:/cmake_test/CMakeFiles/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: Could not find cmake module file:C:/cmake_test/CMakeFiles/CMakeCXXCompiler.cmake
-- Configuring incomplete, errors occurred!
These errors did not help me much. Considering it works in Linux, it must be something related to the Window's configuration.
Thank you for any help!
Configuration:
- Windows 7
- MinGW/GCC 4.6.1
Running CMake for Windows / Microsoft Visual C++ (MSVC)Run cmake-gui.exe, which should be in your Start menu under Program Files, there may also be a shortcut on your desktop, or if you built from source, it will be in the build directory. A GUI will appear similar to what is shown below.
You can check your CMake version by using the command cmake --version. cmake version 3.11. 2CMake suite maintained and supported by Kitware (kitware.com/cmake).
You may have better results with -G "MSYS Makefiles"
instead of "MinGW Makefiles"
- but I warn you - it is going to be slow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With