Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check what compiler cmake is using?

Tags:

c++

cmake

I'm surprised I couldn't find this googling. I only found this, but I want to known how to find what compiler is cmake using in general? I also found this but I assume there is some variable in cmake that just holds the compiler name, right?

like image 543
Hakaishin Avatar asked Jul 03 '18 12:07

Hakaishin


1 Answers

You can see what variables are available in your CMake's binary output directory CMakeFiles/[your CMake's version]/CMakeCXXCompiler.cmake.

If you just want to print it, your are looking for CMAKE_CXX_COMPILER_ID and CMAKE_CXX_COMPILER_VERSION. Those are available cross-platform.

Here are two examples of what CMake detects and generates from my projects:

set(CMAKE_CXX_COMPILER_ID "GNU")
set(CMAKE_CXX_COMPILER_VERSION "4.6.3")

Or

set(CMAKE_CXX_COMPILER_ID "MSVC")
set(CMAKE_CXX_COMPILER_VERSION "19.0.24215.1")

Other kind of variables are there to check for platforms/toolchains like CMAKE_COMPILER_IS_GNUCXX.

like image 163
Florian Avatar answered Sep 22 '22 22:09

Florian