bilke / cmake-modules

Additional CMake functionality. Most of the modules are from Ryan Pavlik (https://github.com/rpavlik/cmake-modules)
Boost Software License 1.0
547 stars 214 forks source link

CodeCoverage.cmake complains about non-GCC compiler even with GCC #61

Closed eyalroz closed 2 years ago

eyalroz commented 3 years ago

I was trying to follow the usage instructions in CodeCoverage.cmake ; but when I loaded the module, I got a notice about the compiler not being GCC and "Aborting...". Yet, I was using GCC. This was on a Devuan GNU/Linux 3 with GCC 8.4.0 and CMake 3.13.

daniel-sintef commented 2 years ago

I also got stuck here, there is a bug in the source where they only check the Fortran compiler instead of the chosen compiler. The code below fixes this (see line 160):

153 if("${CMAKE_${LANG}_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
154     if("${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS 3)
155         message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
156     endif()
157 elseif(NOT CMAKE_COMPILER_IS_GNUCXX)
158     if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "[Ff]lang")
159         # Do nothing; exit conditional without error if true
160     elseif("${CMAKE_${LANG}_COMPILER_ID}" MATCHES "GNU")
161         # Do nothing; exit conditional without error if true
162     else()
163         message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
164     endif()
165 endif()