Cmake if test for gcc

What is the correct way to check if the GCC compiler is under Cmake?

I saw like if(CMAKE_COMPILER_IS_GNUCC)and if(CMAKE_COMPILER_IS_GNUXX), but none of them are defined when I run cmake. To be clear, I am 100% sure that I am using GCC.

I just want to add compiler flags for GCC. I used to just use a sentence elseafter checking windows, but now I want to be more general.

+3
source share
1 answer

I think I found the problem. These properties are not determined only after the instruction project. Switching order around and seems to work.

+3
source

All Articles