其他分享
首页 > 其他分享> > CMake 指定 MinGW 为编译器

CMake 指定 MinGW 为编译器

作者:互联网

在 Windows 中如果不指定编译器,默认使用的是 Windows 的 SDK, 如下样式, 这种不生成 Makefile 无法使用 make 进行编译

E:\project_code\cpp\demo\build>cmake ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.29.30040.0
-- The CXX compiler identification is MSVC 19.29.30040.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/VisualStudio/community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/VisualStudio/community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: E:/project_code/cpp/demo/build

手动指定 cmake 使用的编译器

Linux

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
cmake ..

Windows

cmake -G "MinGW Makefiles" ..

标签:CMake,--,Windows,CXX,编译器,MinGW,done,Detecting,compiler
来源: https://www.cnblogs.com/gldsly/p/15124452.html