user3696153
user3696153

Reputation: 750

CMake variable CMAKE_C_COMPILER_VERSION set but later value lost

So I have a number of CMake files - and I am trying to refactor many common things across multiple projects.

One example is we turn on features due to the compiler version (GCC)

I am having problems with: CMAKE_C_COMPILER_VERSION.

If I run cmake with --trace - I see the following:

/data/project/proj/build/thing.Debug/CMakeFiles/3.22.1/CMakeCCompiler.cmake(4):  set(CMAKE_C_COMPILER_VERSION 9.2.1 )

So - CMake knows the compiler version.

But - later in my CMake scripts I try to reference that variable and do this as a diagnostic:

  message("CMAKE_C_COMPILER_VERSION: ${CMAKE_C_COMPILER_VERSION}")

And On the console output, it is blank:

CMAKE_C_COMPILER_VERSION:

And If I try to reference the variable, it turns into blank. Why is this? Why does one part of CMake - find/understand and set a variable Only so that other parts cannot use the variable.

Upvotes: 0

Views: 25

Answers (0)

Related Questions