Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake if test for GCC

Tags:

gcc

cmake

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

I've seen both if(CMAKE_COMPILER_IS_GNUCC) and if(CMAKE_COMPILER_IS_GNUXX) but neither of those are defined when I run cmake. Just to be clear, I'm 100% sure I'm using GCC.

I just want to add compiler flags specific to GCC. Previously I just used an else clause after a check fro windows, but I want to be more generic now.

like image 825
edA-qa mort-ora-y Avatar asked Nov 28 '25 15:11

edA-qa mort-ora-y


1 Answers

I think I found the problem. Those properties aren't defined until after the project statement. Switching the ordering around and it appears to work.

like image 54
edA-qa mort-ora-y Avatar answered Dec 01 '25 06:12

edA-qa mort-ora-y



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!