CMake 指定 MinGW 爲編譯器

在 Windows 中若是不指定編譯器,默認使用的是 Windows 的 SDK, 以下樣式, 這種不生成 Makefile 沒法使用 make 進行編譯linux

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 使用的編譯器windows

Linux

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

Windows

cmake -G "MinGW Makefiles" ..
相關文章
相關標籤/搜索