Edit

kc3-lang/libevent/cmake/CheckConstExists.cmake

Branch :

  • Show log

    Commit

  • Author : Azat Khuzhin
    Date : 2017-01-30 03:17:41
    Hash : fa135bdc
    Message : cmake: Fix checking of enum values from sysctl.h CheckSymbolExists do not do this, so add new CheckConstExists that will use CheckCSourceCompiles() to check this. v2: use set() instead of string(APPEND)

  • cmake/CheckConstExists.cmake
  • include(CheckCSourceCompiles)
    
    macro(check_const_exists CONST FILES VARIABLE)
      set(check_const_exists_source "")
      foreach(file ${FILES})
        set(check_const_exists_source
            "${check_const_exists_source}
            #include <${file}>")
      endforeach()
      set(check_const_exists_source
          "${check_const_exists_source}
          int main() { (void)${CONST}; return 0; }")
    
      check_c_source_compiles("${check_const_exists_source}" ${VARIABLE})
    
      if (${${VARIABLE}})
        set(${VARIABLE} 1 CACHE INTERNAL "Have const ${CONST}")
        message(STATUS "Looking for ${CONST} - found")
      else()
        set(${VARIABLE} 0 CACHE INTERNAL "Have const ${CONST}")
        message(STATUS "Looking for ${CONST} - not found")
      endif()
    endmacro(check_const_exists)