Home | History | Annotate | Line # | Download | only in cmake
      1  1.1  christos include(CheckCSourceCompiles)
      2  1.1  christos 
      3  1.1  christos macro(check_const_exists CONST FILES VARIABLE)
      4  1.1  christos   if (NOT DEFINED ${VARIABLE})
      5  1.1  christos     set(check_const_exists_source "")
      6  1.1  christos     foreach(file ${FILES})
      7  1.1  christos       set(check_const_exists_source
      8  1.1  christos           "${check_const_exists_source}
      9  1.1  christos           #include <${file}>")
     10  1.1  christos     endforeach()
     11  1.1  christos     set(check_const_exists_source
     12  1.1  christos         "${check_const_exists_source}
     13  1.1  christos         int main() { (void)${CONST}; return 0; }")
     14  1.1  christos 
     15  1.1  christos     check_c_source_compiles("${check_const_exists_source}" ${VARIABLE})
     16  1.1  christos 
     17  1.1  christos     if (${${VARIABLE}})
     18  1.1  christos       set(${VARIABLE} 1 CACHE INTERNAL "Have const ${CONST}")
     19  1.1  christos       message(STATUS "Looking for ${CONST} - found")
     20  1.1  christos     else()
     21  1.1  christos       set(${VARIABLE} 0 CACHE INTERNAL "Have const ${CONST}")
     22  1.1  christos       message(STATUS "Looking for ${CONST} - not found")
     23  1.1  christos     endif()
     24  1.1  christos   endif()
     25  1.1  christos endmacro(check_const_exists)
     26