CMake (2.8.12.2) compiler check on Ubuntu 14.04 fails - gcc

I'm trying to run this simple CMake command:
$ cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++ ./src/
I get the following output:
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/gcc" is not able to compile a simple test program.
The reason for the error is the following:
gcc: error: unrecognized command line option ‘-rpath’
because CMake is trying to link with the following command:
/usr/bin/gcc -rpath /usr/local/openblas/lib
CMakeFiles/cmTryCompileExec1190183239.dir/testCCompiler.c.o -o
cmTryCompileExec1190183239 -rdynamic
to my knowledge there is no stand alone '-rpath' option with gcc. I'm not sure why CMake is trying to do this.
Did anyone else come across this? Solutions?
Thanks!
PS: Some more info that maybe useful:
I'm trying to learn how to use CMake so the directory structure is very simple:
-cmake_test/
-bin/
-src/
-executable.cpp
-CMakeLists.txt
-CMakeLists.txt
Edit:
Complete output for
$ cmake ./src/
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec961681416/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec961681416.dir/build.make
CMakeFiles/cmTryCompileExec961681416.dir/build
make[1]: Entering directory
`/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp/CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec961681416.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec961681416.dir/testCCompiler.c.o
-c
/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTryCompileExec961681416
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec961681416.dir/link.txt --verbose=1
/usr/bin/cc -rpath /usr/local/openblas/lib
CMakeFiles/cmTryCompileExec961681416.dir/testCCompiler.c.o -o
cmTryCompileExec961681416 -rdynamic
cc: error: unrecognized command line option ‘-rpath’
make[1]: *** [cmTryCompileExec961681416] Error 1
make[1]: Leaving directory
`/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec961681416/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
-- Configuring incomplete, errors occurred!
See also "/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeOutput.log".
See also "/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeError.log".

I apologize to everyone... The error resulted from me making a mistake a while ago.
The answer in short is that I had the following incorrect line in my .bashrc file:
export LDFLAGS="-rpath /usr/local/openblas/lib "$LDFLAGS
and CMake has the following line in the CMakeCommonLanguageInclude.cmake module:
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
Which obviously resulted in setting the CMAKE_EXE_LINKER_FLAGS to -rpath /usr/local/openblas/lib and
hence the error. After changing the .bashrc file to:
export LDFLAGS="-Wl,-rpath=/usr/local/openblas/lib "$LDFLAGS
the issue was resolved.
I have no idea why this didn't come up with the GUI version though :-)
I probably messed up the .bashrc file by reading an OSX forum or something.
Anyway thanks for the answers!

Related

How to resolve linker path error when using home-brew clang 13 in CMake project on macOS 12

In order to make use of newer C++ 17 and 20 features, I want to switch from Apple clang to a homebrew installed vanilla clang. I installed it via brew install llvm.
When trying to build a minimal CMake based test project like
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -G Ninja testProject
CMake fails with
-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang - broken
CMake Error at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/local/opt/llvm/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/me/Projects/testProject/build/CLion/Debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/local/bin/ninja cmTC_d2d4b && [1/2] Building C object CMakeFiles/cmTC_d2d4b.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_d2d4b
FAILED: cmTC_d2d4b
: && /usr/local/opt/llvm/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_d2d4b.dir/testCCompiler.c.o -o cmTC_d2d4b && :
ld: library not found for -lSystem
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
So it seems that it fails to locate the correct library search path out of the box.
When trying to build a simple hello world program from the command line like
/usr/local/opt/llvm/bin/clang++ main.cpp -isysroot /Library/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
It fails with even not finding some headers.
Supplying the header and library search path explicitly to the build command like
/usr/local/opt/llvm/bin/clang++ main.cpp -I"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" -L"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
makes it work. However, both are no solutions to make the built-in CMake compiler check work and they don't seem like the correct way to go.
Once this is working correctly, I'm furthermore interested in being able to compile ObjectiveC++ code which currently fails with even more errors.
I think I understand the problem that the compiler does not know the correct search paths, but I'm lacking some understanding about how it would normally figure out those search paths in a CMake project.
I finally managed to get it working by supplying a few linker flags through the LDFLAGS environment variable:
-L/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/usr/lib
In order to find the system libraries needed by the C compiler check
-L/usr/local/opt/llvm/lib
In order to find the C++ libraries as needed by the C++ compiler check
In order to successfully compile Objective-C code that links to Apple frameworks, I furthermore needed to add
-F/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks -lobjc
With those flags, I now can successfully build my projects. Still, I'm not 100% sure if this is the right way, especially if the libraries linked from /usr/local/opt/llvm/lib can be expected to be present on all target systems?

Assimp Compilation Error Using CMake: GCC Cannot Compile Test Program

I am trying to compile Assimp 5.0.1 for Windows 10 using CMake. The C/C++ compilers I have through MinGW are GCC and G++. If I understand the problem correctly, there is an issue with the MakeFile's whitespace somewhere. The /CMakeTmp/ directory is empty, and I am sure the answer is right in front of me somewhere:
Console Output:
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe - broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeTmp
Run Build Command(s):make -f Makefile /nologo cmTC_a4ec5\fast && Makefile:37: *** missing separator. Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:54 (PROJECT)
-- Configuring incomplete, errors occurred!
See also "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeOutput.log".
See also "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeError.log".
CMakeError.log:
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeTmp
Run Build Command(s):make -f Makefile /nologo cmTC_165dc\fast && Makefile:37: *** missing separator. Stop.
CMakeOutput.log:
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/MinGW/bin/gcc.exe
Build flags:
Id flags:
The output was:
0
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.exe"
The C compiler identification is GNU, found in "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/3.20.2/CompilerIdC/a.exe"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/MinGW/bin/g++.exe
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.exe"
The CXX compiler identification is GNU, found in "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/3.20.2/CompilerIdCXX/a.exe"
Which -G option did you use for cmake?
The /nologo parameter for make doesn't seem right, that looks like a Microsoft/MSVC parameter. If you didn't specify -G then CMake defaults to -G"NMake Makefiles" on Windows.
Make sure to use cmake flag -G"MinGW Makefiles" for mingw32-make or -G"MSYS Makefiles" if you use MSYS' make.
But to avoid all those make issues and improve speed -GNinja is the best solution, provided you have Ninja available (see https://ninja-build.org/).
Finally, you're still on MinGW GCC 9.2.0. Newer versions are available, see http://winlibs.com/ for standalone builds which also come with newer mingw32-make.

How to use cmake to let command "pkg_check_modules" be passed in Windows with git-bash

I want to build nss-pem on Windows by cmake with git-bash(or msys or cygwin). cmake found pkg-config in my cygwin's bin directory. I also added the directory path into PKG_CONFIG_PATH, and added .pc file and built-nss-lib into the directory I added. But I still got error when cmake exe the line pkg_check_modules(NSS REQUIRED "nss")
$PKG_CONFIG_PATH:
User#host MINGW64 ~/Desktop/nss-pem/build
$ echo $PKG_CONFIG_PATH
/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
CMake Error:
User#host MINGW64 ~/Desktop/nss-pem/build
$ cmake ../src
-- Checking for module 'nss'
-- No package 'nss' found
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:412 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:588 (_pkg_check_modules_internal)
CMakeLists.txt:7 (pkg_check_modules)
nss.pc:
# nss pkg-config
prefix=D:/Projects/library/nss
exec_prefix=${prefix}
includedir=${prefix}
libdir=${exec_prefix}/WIN954.0_x86_64_64_OPT.OBJ/lib/
Name: nss
Description: The nss library
Version: 3.32
Cflags: -I${includedir}/WIN954.0_x86_64_64_OPT.OBJ/include -I${includedir}/public/nss
Libs: -L${libdir} -lnss3 -lnspr4
What is the correct way to build this project? And what is the best way to setup the unix-like environment to build projects on Windows?
 
Update
I try to use git-bash and add cygwin/bin into my env variables. The command I used to call cmake is cmake -G "MSYS Makefiles" ../src. It seems that it occur some errors of path.
$ cmake -G "MSYS Makefiles" ../src
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: C:/cygwin/bin/gcc.exe
-- Check for working C compiler: C:/cygwin/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/CMakeTestCCompiler .cmake:51 (message):
The C compiler "C:/cygwin/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: C:/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/cygwin/bin/make.exe" "cmTC_bdb42/fast"
/usr/bin/make -f CMakeFiles/cmTC_bdb42.dir/build.make
CMakeFiles/cmTC_bdb42.dir/build
make[1]: Entering directory
'/cygdrive/c/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeTmp'
/bin/sh: /C/Program Files/CMake/bin/cmake.exe: No such file or directory
make[1]: *** [CMakeFiles/cmTC_bdb42.dir/build.make:65:
CMakeFiles/cmTC_bdb42.dir/testCCompiler.c.obj] Error 127
make[1]: Leaving directory
'/cygdrive/c/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_bdb42/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeError.log".
/bin/sh: /C/Program Files/CMake/bin/cmake.exe: No such file or directory: bash could not find cmake.exe, even if I modified the CMakeCache.txt. And the C compiler checking always fail. (I can manually compile the test file.)
So I gave up to work with git-bash, and turn to use Windows' cmd.exe with MinGW. Below is the steps what I done.
Clean up PATH env variables (remove cygwin's dirs).
Copy pkg-config.exe and the required dynamic libraries into MinGW/bin.
Create MinGW/lib/pkgconfig/nss.pc.
Below is the message returned:
C:\Users\IvenCJ7\Desktop\nss-pem\build>cmake -G "MinGW Makefiles" ../src
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: C:/MinGW/bin/pkg-config.exe (found version "0.29.1")
-- Checking for module 'nss'
-- Found nss, version 3.32
-- Looking for lowkeyti.h
-- Looking for lowkeyti.h - found
-- Looking for NSSCKFWSlot_GetSlotID
-- Looking for NSSCKFWSlot_GetSlotID - not found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/User/Desktop/nss-pem/build
cmake still cannot find the function, NSSCKFWSlot_GetSlotID in NSS. I made sure the function is in the NSS's include headers.
Below is the information that pkg-config return to me.
$ pkg-config --cflags --libs nss
-ID:/Projects/library/nss/WIN954.0_x86_64_64_OPT.OBJ/include
-ID:/Projects/library/nss/public/nss
-LD:/Projects/library/nss/WIN954.0_x86_64_64_OPT.OBJ/lib/ -lnss3 -lnspr4

CMake reports broken g++ and missing libiconv-2.dll

I have some strange problem with CMake when I press Configure button.
It reports me all the time that libiconv-2.dll is missing and fails to finish operation. However, this library is present in MinGW/bin folder.
I am using CodeBlocks-MinGW Makefiles and CMake version 3.6.1 - 32 bit version (although this same problem is with 64 bit version).
One interesting thing is that in consol it shows:
The CXX compiler identification is unknown
Check for working CXX compiler: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.exe -- broken
MinGW is correctly added to the system path and I was able to check version (GNU 4.8.1) and also compile simple hello world from command line using:
g++ test.cpp -o test
Testing this same CMakeLists file on another machine with this same configuration, but older CMake version 3.2.3 everything works. Doing some research online I've found that problem with this file is not new, so I doubt this is version problem.
Anyone has any idea what can be done more?
EDIT 1
This is the content of CMakeError.log
Compiling the CXX compiler identification source file
"CMakeCXXCompilerId.cpp" failed. Compiler: C:/MinGW/bin/g++.exe Build
flags: Id flags:
The output was: 1
Compiling the CXX compiler identification source file
"CMakeCXXCompilerId.cpp" failed. Compiler: C:/MinGW/bin/g++.exe Build
flags: Id flags: -c
The output was: 1
Checking whether the CXX compiler is IAR using "" did not match "IAR
.+ Compiler": g++.exe: fatal error: no input files compilation
terminated. Determining if the CXX compiler works failed with the
following output: Change Dir:
C:/Users/testuser/Desktop/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_c9a03/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_c9a03.dir\build.make
CMakeFiles/cmTC_c9a03.dir/build
mingw32-make.exe1: Entering directory
'C:/Users/testuser/Desktop/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_c9a03.dir/testCXXCompiler.cxx.obj
C:\MinGW\bin\g++.exe -o
CMakeFiles\cmTC_c9a03.dir\testCXXCompiler.cxx.obj -c
C:\Users\testuser\Desktop\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
CMakeFiles\cmTC_c9a03.dir\build.make:64: recipe for target
'CMakeFiles/cmTC_c9a03.dir/testCXXCompiler.cxx.obj' failed
mingw32-make.exe1: ***
[CMakeFiles/cmTC_c9a03.dir/testCXXCompiler.cxx.obj] Error 1
mingw32-make.exe1: Leaving directory
'C:/Users/testuser/Desktop/build/CMakeFiles/CMakeTmp'
Makefile:125: recipe for target 'cmTC_c9a03/fast' failed
mingw32-make.exe: *** [cmTC_c9a03/fast] Error 2
I have manually compiled the file testCXXCompiler.cpp with g++ and it worked. There was no error during compilation.
EDIT 2
I have created SSCCE to test if problem isn't with some dependencies or some other code-related things. But testing this file:
test.cpp
#include <iostream>
int main()
{
std::cout << "Test" << std::endl;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(Test)
add_executable(Test test.cpp)
I have still problems with missing library. The console output changed however slightly and now it is:
The C compiler identification is unknown
The CXX compiler identification is unknown
Check for working C compiler: C:/MinGW/bin/gcc.exe
Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
I suppose I have found the answer. At least it is working for me.
Apparently I needed to run the CMake on the other machine as an Administrator. This way I assume it could accessed to GCC files correctly. However, I am not completely sure why on the other machine it wasn't required and worked just fine.
You might need to reinstall the lib
mingw-get install --reinstall mingw32-libiconv-dll
I had a very similar problem, and it was fixed this way.

Unable to specify the compiler with CMake

I have a problem with this CMakeLists.txt file:
cmake_minimum_required(VERSION 2.6)
SET(CMAKE_C_COMPILER C:/MinGW/bin/gcc)
SET(CMAKE_CXX_COMPILER C:/MinGW/bin/g++)
project(cmake_test)
add_executable(a.exe test.cpp)
Calling cmake with: cmake -G "MinGW Makefiles" , it fails with the following output:
c:\Users\pietro.mele\projects\tests\buildSystem_test\cmake_test>cmake -G "MinGW Makefiles" .
-- The C compiler identification is GNU 4.6.1
-- The CXX compiler identification is GNU 4.6.1
-- Check for working C compiler: C:/MinGW/bin/gcc
CMake Error: your C compiler: "C:/MinGW/bin/gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: C:/MinGW/bin/gcc -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "C:/MinGW/bin/gcc" is not able to compile a simple test
program.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:10 (project)
CMake Error: your C compiler: "C:/MinGW/bin/gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "C:/MinGW/bin/g++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!
However the gcc compiler is in C:/MinGW/bin/ and it works.
Any idea?
Platform:
Windows 7
MinGW/GCC 4.6
Never try to set the compiler in the CMakeLists.txt file.
See the CMake FAQ about how to use a different compiler:
https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler
(Note that you are attempting method #3 and the FAQ says "(avoid)"...)
We recommend avoiding the "in the CMakeLists" technique because there are problems with it when a different compiler was used for a first configure, and then the CMakeLists file changes to try setting a different compiler... And because the intent of a CMakeLists file should be to work with multiple compilers, according to the preference of the developer running CMake.
The best method is to set the environment variables CC and CXX before calling CMake for the very first time in a build tree.
After CMake detects what compilers to use, it saves them in the CMakeCache.txt file so that it can still generate proper build systems even if those variables disappear from the environment...
If you ever need to change compilers, you need to start with a fresh build tree.
I had similar problem as Pietro,
I am on Window 10 and using "Git Bash".
I tried to execute >>cmake -G "MinGW Makefiles", but I got the same error as Pietro.
Then, I tried >>cmake -G "MSYS Makefiles", but realized that I need to set my environment correctly.
Make sure set a path to C:\MinGW\msys\1.0\bin and check if you have gcc.exe there. If gcc.exe is not there then you have to run C:/MinGW/bin/mingw-get.exe and install gcc from MSYS.
After that it works fine for me
Using with FILEPATH option might work:
set(CMAKE_CXX_COMPILER:FILEPATH C:/MinGW/bin/gcc.exe)
I had the same issue. And in my case the fix was pretty simple. The trick is to simply add the ".exe" to your compilers path. So, instead of :
SET(CMAKE_C_COMPILER C:/MinGW/bin/gcc)
It should be
SET(CMAKE_C_COMPILER C:/MinGW/bin/gcc.exe)
The same applies for g++.

Resources