问题
I have a CMake project I want to compile with g++. The project compiles and runs on Linux. Now I am trying to get it working on Windows.
For that reason, I installed MinGW and added it to the PATH and I am using Git Bash. In order to force CMake to use g++ I added these env variables:
CC = C:\MinGW\bin\gcc
CXX = C:\MinGW\bin\g++
But when I run CMake it does not detect any compilers and tells me:
-- The C compiler identification is unkown
-- The CXX compiler identification is unkown
I created a super basic example on github which I would like to get running on Windows + MinGw: https://github.com/j-o-d-o/Basic-CMake-Project
How can I use the env variables in windows to force CMake to use g++ and gcc compiler?
回答1:
I needed to add -G "MinGW Makefiles"
to the CMake command.
I check if I am on Windows and if yes, I add the parameter to the CMake command in the shell script.
I also need to use mingw32-make
instead of make
when I am on Windows.
There are some other issues now, but it resolves the issue/question I have posted.
来源:https://stackoverflow.com/questions/51979949/cmake-can-not-find-g-compiler-on-windows