Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set C or C++ compiler for CMake

📅 2013-Dec-24 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cmake, compiler ⬩ 📚 Archive

Sometimes you might need to use a different version of a default compiler (like gcc) or a different compiler (like Intel compiler) to build your code. Specifying this is easy in CMake. Add these lines to your CMakeLists.txt:

SET(CMAKE_C_COMPILER /path/to/c/compiler)
SET(CMAKE_CXX_COMPILER /path/to/cpp/compiler)

Tried with: CMake 2.8.7 and Ubuntu 12.04 LTS


© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email