[cmake-developers] [CMake 0011629]: CheckCCompilerFlag quirk.

Mantis Bug Tracker mantis at public.kitware.com
Sun Dec 19 07:41:57 EST 2010


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=11629 
====================================================================== 
Reported By:                Campbell Barton
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11629
Category:                   (No Category)
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2010-12-19 07:41 EST
Last Modified:              2010-12-19 07:41 EST
====================================================================== 
Summary:                    CheckCCompilerFlag quirk.
Description: 
Hi, we were having some problems with warnings and gcc versions so I
thought to write a macro that adds a flag to any string (typically
CMAKE_C_FLAGS)

ADD_CHECK_C_COMPILER_FLAG(CMAKE_C_FLAGS -Wno-unknown-pragmas)

...this is the macro.

macro(ADD_CHECK_C_COMPILER_FLAG
       _CFLAGS
       _FLAG)

       include(CheckCCompilerFlag)

       # odd workaround
       set(CFLAG_TEST "CFLAG_TEST")
       CHECK_C_COMPILER_FLAG("${_FLAG}" CFLAG_TEST)
       if(CFLAG_TEST)
               # message(STATUS "Using CFLAG: ${_FLAG}")
               set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}")
       else()
               message(STATUS "Unsupported CFLAG: ${_FLAG}")
       endif()
endmacro()


My question is why this is needed?
       set(CFLAG_TEST "CFLAG_TEST")
       CHECK_C_COMPILER_FLAG("${_FLAG}" CFLAG_TEST)

If I do this (as I see in other examples online)...
       CHECK_C_COMPILER_FLAG("${_FLAG}" CFLAG_TEST)

This if check fails in CheckCSourceCompiles.cmake:28 ...

MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR)
 IF("${VAR}" MATCHES "^${VAR}$")

This is confusing since from what I can tell CFLAG_TEST can be an
undefined variable.
Any idea whats going on?
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-12-19 07:41 Campbell BartonNew Issue                                    
======================================================================




More information about the cmake-developers mailing list