How can I make CMake use GCC instead of Clang on Mac OS X?

后端 未结 4 1197
陌清茗
陌清茗 2020-12-12 16:26

I can\'t find any info on it, but only the other way around (e.g., how to set CMake to use clang).

I\'ve installed gcc-4.8 using brew, setup all dependencies, header

4条回答
  •  盖世英雄少女心
    2020-12-12 16:57

    CMake doesn't (always) listen to CC and CXX. Instead use CMAKE_C_COMPILER and CMAKE_CXX_COMPILER:

    cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ...
    

    See also the documentation.

    Alternatively, you can provide a toolchain file, but that might be overkill in this case.

提交回复
热议问题